gnuplot:将columnheader设置为标签 [英] gnuplot: set columnheader as label
问题描述
是否可以将数据文件列的标题设置为标签(而不是键)?
Is there a chance to set the header of the data file columns as label (not as key)?
我有5或6列的数据文件,每列上方都有一个标题.现在,我想在set label
命令中使用columnheader.这可能吗?
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?
推荐答案
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 没有head
命令,您可以使用
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.
word()
函数应在与columnhead()
相同的位置拆分标题字符串.当然,除非您使用其他分隔符(不是空格或制表符):
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]
...
这篇关于gnuplot:将columnheader设置为标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!