用于循环输出的Gnuplot
我有两个不同的文本文件,分别有一个数据列和一个值列。Ĩ想使用“plot for”循环来打印这两个文件,但我想更改输出的名称以匹配我正在打印的文件。现在,我的代码如下所示:用于循环输出的Gnuplot,gnuplot,Gnuplot,我有两个不同的文本文件,分别有一个数据列和一个值列。Ĩ想使用“plot for”循环来打印这两个文件,但我想更改输出的名称以匹配我正在打印的文件。现在,我的代码如下所示: set terminal postscript eps color set out "test.eps" set size 0.6 set multiplot set xdata time set timefmt "%Y-%m" set format x "%b\n%y" set xtics "2004-01", 12*262
set terminal postscript eps color
set out "test.eps"
set size 0.6
set multiplot
set xdata time
set timefmt "%Y-%m"
set format x "%b\n%y"
set xtics "2004-01", 12*2629746, "2016-12"
filenames = 'ArcheryData.txt CanyoningData.txt'
plot for [file in filenames] file u 1:2 w l title file
现在我得到的是test.eps文件,它将两个数据文件绘制在同一个图形中。在这种情况下,您可以使用
do
循环作为:
set terminal postscript eps color
set size 0.6
set xdata time
set timefmt "%Y-%m"
set format x "%b\n%y"
set xtics "2004-01", 12*2629746, "2016-12"
do for [ name in "ArcheryData CanyoningData" ]{
set output name.".eps"
plot name.".txt" u 1:2 w l title name
}
或者,可以在调用Gnuplot时指定变量name
,因此脚本如下:
set terminal postscript eps color
set size 0.6
set xdata time
set timefmt "%Y-%m"
set format x "%b\n%y"
set xtics "2004-01", 12*2629746, "2016-12"
set output name.".eps"
plot name.".txt" u 1:2 w l title name
然后可以将其用作gnuplot-e“name='ArcheryData';”fig.gpl