Gnuplot, how to include a space character in key titles?

大兔子大兔子 提交于 2019-12-23 18:07:19

问题


I want to use key titles like "Best F" "Worst F" for a gnuplot 4.4 graph, when reading the data from a file, but I can't figure out how to put the space, e.g.:

Generation Best_F Worst_F Average_F
     5        4     9         5
     4        3     9         4

I tried writing in the file "Best F", "Best%20F" "Best\ F" but they get split, when read as column headers, or I get the ugly looking "%20".

plot for[col=2:4] data.dat using 1:col title columnheader(col)

Or is there a way to do a character substitution, like "Best_F"%" "->"Best F"? replace("_", "\ ", columheader(col))?

I am using terminals wxt and pngcairo (no latex). Thanks


回答1:


Per the Datastrings section of the manual (that's an old version, but unfortunately later ones haven't been published in HTML), strings in data files are delimited with double quotes. If I modify your example data file to be like this, then I get titles with spaces, when I run it under gnuplot 4.6 patchlevel 1 (with datastrings enabled).

Generation "Best F" "Worst F" "Average F"
     5        4     9         5
     4        3     9         4

Program:

plot for[col=2:4] "data.txt" using 1:col title columnheader(col)

Output excerpt:




回答2:


With the Enhanced Postscript you can create spaces of variable width:

Generation Best&{x}F Worst&{x}F Average&{x}F
     5        4         9           5
     4        3         9           4

where you can replace x with a string of desired length. However, this requires a terminal that allows

set termoption enhanced

This is especially useful if you want to useawkto process files based on the headers and autolabel them in gnuplot based on the columnheader.



来源:https://stackoverflow.com/questions/15013134/gnuplot-how-to-include-a-space-character-in-key-titles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!