gnuplot: set columnheader as label

后端 未结 1 630
庸人自扰
庸人自扰 2021-01-24 09:54

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 lik

1条回答
  •  执笔经年
    2021-01-24 10:47

    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]
    ...
    

    0 讨论(0)
提交回复
热议问题