gnuplot: set columnheader as label

蓝咒 提交于 2019-12-20 05:35:10

问题


Is there a chance to set the header of the data file columns as label (not as key)?

I have data files with 5 or 6 columns and a header above each column. Now I would like to use the columnheader with the set label command. Is this possible?


回答1:


On a unixoid system, the head command helps:

header = system("head -n 1 ".filename)
label1 = word(header,1)
label2 = word(header,2)
...
set label 1 at 0.5,0.5 label1
set label 2 ....

MS win does not have the head command, you might use 'findstr /B \"#\"' instead, if the header line begins with a "#". Or use cygwin to get a full GNU + POSIX environment under Windows.

The word() function should split your header string at the same positions as columnhead(). Unless of course you have a different separator (not space or tab):

separator =","
p1 = strstrt(header,separator)
p2 = strstrt(header[p1+1:],separator)
...
label1=header[1:p1-1]
...


来源:https://stackoverflow.com/questions/32394606/gnuplot-set-columnheader-as-label

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