【发布时间】:2018-02-19 14:44:51
【问题描述】:
关于gnuplot中columnheader的两个问题:
1) 我正在绘制一些带有列标题的数据列,并且我想在每条图形线的末端(带有“结束”)和一个键中标记图形。如果我使用“未设置键”,我会在图表末尾得到干净的标签。
unset key
plot for [col=2:6] file using 1:col with lp ls col title columnhead(col) at end
如果我注释掉“未设置键”并尝试在每个图的末尾和键中绘制两个标签,我会在正确绘制的键的右侧得到一些奇怪的工件。有什么办法可以摆脱这个神器?
### unset key
plot for [col=2:6] file using 1:col with lp ls col title columnhead(col), for [col=2:6] file using 1:col with lp ls
col title columnhead(col) at end
2) 有时我在标记时需要列标题的子字符串。我尝试了“substr”(见下文),但得到的是“0”,而不是子字符串。有没有办法获取列标题的子字符串?
plot for [col=2:6] file using 1:col with lp ls col title substr(columnhead(col),0,1) at end
编辑:示例数据文件:
Date,V,W,D,Y,X
2017-09-03,0,0,0,0,-
2017-09-05,-3.67,-4.71,-2.86,-1.69,-
2017-09-06,-4.19,-6.42,-1.65,-1.86,-
2017-09-07,-2.41,-5.64,1.24,-0.26,0
2017-09-08,4.61,-5.38,1.47,0.45,-2.55
EDIT2:即使是这个带有上述数据的简单脚本也给了我工件(Win7 x64,gnuplot 5.2)
set terminal gif
set output "test.gif"
set datafile separator ","
set timefmt "%Y-%m-%d"
set xdata time
plot for [col=2:6] "test.dat" using 1:col with lp ls col title columnhead(col) at end
【问题讨论】:
-
您能发布您的数据文件和完整的 gnuplot 脚本吗?我认为您不必将每一行绘制两次:如果您使用
title ... at end,标题将同时出现在行尾和图例中。 -
我编辑了 OP 以添加示例数据文件。 gnuplot 脚本有点太长,无法发布。如果我使用“title ... at end”而不使用“unset key”,我会在最后得到标签,没有正确的键,而那个奇怪的工件本身就在左下角。我做了两次绘图以获得正确绘制的键。
-
也许你想把你的第二个问题拆分成一个新帖子。
-
算了,第二个问题是另一个bug。报告也在 sf.net 上。
-
感谢您的错误报告。至于将 columnhead(col) 视为字符串并在绘图时对其进行操作: "substr(columnhead(col),0,1)" 对我不起作用, (columnhead(col))[0:1] 不起作用'不起作用,word(columnhead(col),1) 不起作用(我得到“0”),但 sprintf("%s",columnhead(col)) 起作用。
标签: gnuplot columnheader