我发现在gnuplot中,可以从一个文件中获取多个曲线/数据集:
splot "file.dat" using 1:2:3, splot "file.dat" using 1:4:5
Run Code Online (Sandbox Code Playgroud)
也可以将数据嵌入脚本中,如下所示:
splot "-" using 1:2:3
1 0 1
1 2 3
0.5 3 1.5
Run Code Online (Sandbox Code Playgroud)
但是,以下似乎不起作用:
splot "-" using 1:2:3, "-" using 1:4:5
1 0 1 4 4
1 2 3 3 4
0.5 3 1.5 2.5 -1
Run Code Online (Sandbox Code Playgroud)
这是故意的吗,是否存在解决方法?或者根本不可能吗?
Gnuplot 5.0.1数据块
main.gnuplot
$data << EOD
1 0.5 0.25 2 4
2 1 1 4 8
3 1.5 2.25 6 12
4 2 4 8 16
5 2.5 6.25 10 20
6 3 9 12 24
7 3.5 12.25 14 28
8 4 16 16 32
9 4.5 20.25 18 36
10 5 25 20 40
11 5.5 30.25 22 44
12 6 36 24 48
EOD
splot \
"$data" using 1:2:3 with linespoints title "y = x/2, z = y^2", \
"$data" using 1:4:5 with linespoints title "y = 2x, z = 2*y"
Run Code Online (Sandbox Code Playgroud)
转换为PNG:
gnuplot -e 'set terminal png' -e 'set output "main.png"' main.gnuplot
Run Code Online (Sandbox Code Playgroud)
输出:
Ubuntu 15.04具有gnuplot5-x11软件包。
在Ubuntu 14.04上,您可以使用以下命令轻松地从源代码编译gnuplot:
cvs -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot login
cvs -z3 -d:pserver:anonymous@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot co -P gnuplot
cd gnuplot
cvs update -r Release_5_0_1
sudo apt-get build-dep gnuplot
sudo apt-get install lua5.2
./prepare
./configure
time make
sudo make install
gnuplot --version
Run Code Online (Sandbox Code Playgroud)
是的,在撰写本文时,该项目正在使用CVS!
在Ubuntu 18.10,gnuplot 5.2上测试。
以下脚本可以按预期与Gnuplot 4.4一起使用。输出如下
set terminal png
set output 'e.png'
splot "-" using 1:2:3, "" using 1:2:3
1 0 1 4 4
1 2 3 3 4
0.5 3 1.5 2.5 -1
e
1 4 4
1 3 4
0.5 2.5 -1
e
set output
Run Code Online (Sandbox Code Playgroud)