【发布时间】:2015-12-13 10:44:24
【问题描述】:
我正在使用 gnuplot scrip 命令set key autotitle columnhead 为我的数据制作标签。唯一的问题是,列头数据是数字,因此它本身并没有多大意义。
有没有办法给自动标题添加一个固定的字符串,例如"Year " + columnhead,或者给我的键一个标题?
【问题讨论】:
我正在使用 gnuplot scrip 命令set key autotitle columnhead 为我的数据制作标签。唯一的问题是,列头数据是数字,因此它本身并没有多大意义。
有没有办法给自动标题添加一个固定的字符串,例如"Year " + columnhead,或者给我的键一个标题?
【问题讨论】:
在 gnuplot v4.6 (documentation) 中使用 . 运算符和 columnhead() 进行字符串连接:
set terminal pngcairo enhanced truecolor size 480,320 fontscale 0.8
set output 'autotitle.png'
set key left Left
plot for [i=2:4] 'data.txt' u 1:i w l t 'f(x) = '.columnhead(i)
另外,是的,您可以为密钥设置标题,如下所示:set key title 'f(x)'。
本例中使用的输入文件data.txt:
x 100x x^3 2^x
1 100 1 2
2 200 8 4
3 300 27 8
4 400 64 16
5 500 125 32
6 600 216 64
7 700 343 128
8 800 512 256
9 900 729 512
10 1000 1000 1024
【讨论】: