Bash 如何让gnuplot 4.0自动使用最上面的行条目作为标题?
我使用title列、columheader等为GNUPlot 4.2+找到了许多解决这个问题的方法。但是,我一直使用GNUPlot 4.0,需要找到一种方法,使用我的数据集的顶行自动设置标题 我正在使用bash脚本生成一个包含数据的动态(->每日更改)文件,我有一个包含gnuplot设置的静态.gnu文件 你有什么建议吗 (也许是在.gnu文件中使用变量/数组的一种方法?技巧是使用 示例代码:Bash 如何让gnuplot 4.0自动使用最上面的行条目作为标题?,bash,gnuplot,Bash,Gnuplot,我使用title列、columheader等为GNUPlot 4.2+找到了许多解决这个问题的方法。但是,我一直使用GNUPlot 4.0,需要找到一种方法,使用我的数据集的顶行自动设置标题 我正在使用bash脚本生成一个包含数据的动态(->每日更改)文件,我有一个包含gnuplot设置的静态.gnu文件 你有什么建议吗 (也许是在.gnu文件中使用变量/数组的一种方法?技巧是使用 示例代码: #文件内容 $cat data.txt 标题 1. 2. 3. 4. 5. #生成gnuplot脚本
#文件内容
$cat data.txt
标题
1.
2.
3.
4.
5.
#生成gnuplot脚本
$echo“设置术语为哑;绘图”
# content of file
$ cat data.txt
header
1
2
3
4
5
# generate gnuplot script
$ echo "set term dumb; plot '<(tail -n +2 data.txt)' title '$(head -1 data.txt)'"
set term dumb; plot '<(tail -n +2 data.txt)' title 'header'
# pipe to gnuplot
$ echo "set term dumb; plot '<(tail -n +2 data.txt)' title '$(head -1 data.txt)'" | gnuplot
# or you can use `here-doc` (note: `>` is bash prompt)
$ gnuplot <<_EOF_
> set term dumb
> plot '<(tail -n +2 data.txt)' title '$(head -1 data.txt)'
>_EOF_
5 ++-------+--------+-------+--------+--------+--------+-------+-------+A
+ + + + + + + header A +
4.5 ++ ++
| |
| |
4 ++ A ++
| |
3.5 ++ ++
| |
| |
3 ++ A ++
| |
2.5 ++ ++
| |
| |
2 ++ A ++
| |
1.5 ++ ++
| |
+ + + + + + + + +
1 A+-------+--------+-------+--------+--------+--------+-------+-------++
0 0.5 1 1.5 2 2.5 3 3.5 4