gnuplot: set columnheader as label

2020-04-19 07:00发布

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条回答
甜甜的少女心
2楼-- · 2020-04-19 07:15

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]
...
查看更多
登录 后发表回答