无法使用 gnuplot 在一个图中组合三个图形
failed to combine three graphs in one plot using gnuplot
我正在尝试 运行 gnuplot
获取一个图中所有列的图表。
我有一个包含四列的输出文件转储。
1)Input
2)Ref Output
3)Optimization Output
4)Error between ref and opt output
我正在尝试 运行 使用以下内容的命令来获取一张图表,但我得到的是三张图表而不是一张。
我尝试为所有三个图形输入相同的名称 *.png,但这没有用。
你能指导我将所有三个图表合并为一个图表吗?
我的 plot.gpl
文件是:
set xlabel "x"
set ylabel "y"
set xtics 1
set ytics
set grid
set key
set ytics nomirror
set xrange [-1:1]
set yrange [0:4]
plot "dump.txt" using 1:2 with lines axes x1y1 title "Ref output" linecolor rgb "#FF0000"
set terminal png size 1024,768 font ",12"
set output "ref.png"
replot
set xrange [-1:1]
set yrange [0:4]
plot "dump.txt" using 1:3 with lines axes x1y1 title "optimization output" linecolor rgb "#FF0000"
set terminal png size 1024,768 font ",12"
set output "Opt.png"
replot
set xrange [-1:1]
set yrange [-0.0025:0.0025]
plot "dump.txt" using 1:4 with lines axes x1y1 title "Error between stdRef and opt" linecolor rgb "#FF0000"
set terminal png size 1024,768 font ",12"
set output "Error.png"
replot
编辑:
我的数据:
-0.990000 3.141593 1.141593 0.000000
-0.980000 3.000053 1.000052 0.000001
-0.970000 2.941258 1.941257 0.000000
-0.960000 2.896027 1.896024 0.000003
-0.950000 2.857799 1.857796 0.000002
-0.940000 2.824032 1.824029 0.000003
-0.930000 2.793427 1.793428 -0.000001
-0.920000 2.765209 1.765207 0.000003
-0.910000 2.738877 1.738878 -0.000000
-0.900000 2.714081 1.714082 -0.000002
-0.890000 2.690566 1.690559 0.000007
-0.880000 2.668142 1.668132 0.000010
-0.870000 2.646659 1.646653 0.000006
-0.860000 2.625999 1.626004 -0.000005
-0.850000 2.606066 1.606066 -0.000000
-0.840000 2.586782 1.586779 0.000003
-0.830000 2.568080 2.568079 0.000001
-0.820000 2.549904 1.549904 0.000000
-0.810000 2.532207 2.532198 0.000009
-0.800000 2.514949 2.514940 0.000009
-0.790000 2.498092 1.498087 0.000005
-0.780000 2.481606 1.481620 -0.000015
-0.770000 2.465462 1.465458 0.000004
-0.760000 2.449638 1.449627 0.000010
-0.750000 2.434110 2.434114 -0.000004
-0.740000 2.418859 2.418869 -0.000011
-0.730000 2.403867 1.403871 -0.000004
-0.720000 2.389119 2.389119 -0.000000
-0.710000 2.374599 2.374595 0.000004
-0.700000 2.360295 2.360290 0.000005
这可能就是您要找的。无需重新绘制。
代码:
### three curves in one plot with two y-axes
reset session
set terminal png size 1024,768 font ",12"
set output "myOutput.png"
set xlabel "x"
set xrange [-1:1]
set xtics 1
set ylabel "y"
set yrange [0:4]
set ytics nomirror
set y2label "y2"
set y2range [-0.0025:0.0025]
set y2tics nomirror
set grid
set key
plot 'dump.txt' u 1:2 w l axes x1y1 ti "Ref output" lc rgb "red", \
'' u 1:3 w l axes x1y1 ti "optimization output" lc rgb "green", \
'' u 1:4 w l axes x1y2 ti "Error between stdRef and opt" lc rgb "blue"
set output
### end of code
我正在尝试 运行 gnuplot
获取一个图中所有列的图表。
我有一个包含四列的输出文件转储。
1)Input
2)Ref Output
3)Optimization Output
4)Error between ref and opt output
我正在尝试 运行 使用以下内容的命令来获取一张图表,但我得到的是三张图表而不是一张。
我尝试为所有三个图形输入相同的名称 *.png,但这没有用。
你能指导我将所有三个图表合并为一个图表吗?
我的 plot.gpl
文件是:
set xlabel "x"
set ylabel "y"
set xtics 1
set ytics
set grid
set key
set ytics nomirror
set xrange [-1:1]
set yrange [0:4]
plot "dump.txt" using 1:2 with lines axes x1y1 title "Ref output" linecolor rgb "#FF0000"
set terminal png size 1024,768 font ",12"
set output "ref.png"
replot
set xrange [-1:1]
set yrange [0:4]
plot "dump.txt" using 1:3 with lines axes x1y1 title "optimization output" linecolor rgb "#FF0000"
set terminal png size 1024,768 font ",12"
set output "Opt.png"
replot
set xrange [-1:1]
set yrange [-0.0025:0.0025]
plot "dump.txt" using 1:4 with lines axes x1y1 title "Error between stdRef and opt" linecolor rgb "#FF0000"
set terminal png size 1024,768 font ",12"
set output "Error.png"
replot
编辑: 我的数据:
-0.990000 3.141593 1.141593 0.000000
-0.980000 3.000053 1.000052 0.000001
-0.970000 2.941258 1.941257 0.000000
-0.960000 2.896027 1.896024 0.000003
-0.950000 2.857799 1.857796 0.000002
-0.940000 2.824032 1.824029 0.000003
-0.930000 2.793427 1.793428 -0.000001
-0.920000 2.765209 1.765207 0.000003
-0.910000 2.738877 1.738878 -0.000000
-0.900000 2.714081 1.714082 -0.000002
-0.890000 2.690566 1.690559 0.000007
-0.880000 2.668142 1.668132 0.000010
-0.870000 2.646659 1.646653 0.000006
-0.860000 2.625999 1.626004 -0.000005
-0.850000 2.606066 1.606066 -0.000000
-0.840000 2.586782 1.586779 0.000003
-0.830000 2.568080 2.568079 0.000001
-0.820000 2.549904 1.549904 0.000000
-0.810000 2.532207 2.532198 0.000009
-0.800000 2.514949 2.514940 0.000009
-0.790000 2.498092 1.498087 0.000005
-0.780000 2.481606 1.481620 -0.000015
-0.770000 2.465462 1.465458 0.000004
-0.760000 2.449638 1.449627 0.000010
-0.750000 2.434110 2.434114 -0.000004
-0.740000 2.418859 2.418869 -0.000011
-0.730000 2.403867 1.403871 -0.000004
-0.720000 2.389119 2.389119 -0.000000
-0.710000 2.374599 2.374595 0.000004
-0.700000 2.360295 2.360290 0.000005
这可能就是您要找的。无需重新绘制。
代码:
### three curves in one plot with two y-axes
reset session
set terminal png size 1024,768 font ",12"
set output "myOutput.png"
set xlabel "x"
set xrange [-1:1]
set xtics 1
set ylabel "y"
set yrange [0:4]
set ytics nomirror
set y2label "y2"
set y2range [-0.0025:0.0025]
set y2tics nomirror
set grid
set key
plot 'dump.txt' u 1:2 w l axes x1y1 ti "Ref output" lc rgb "red", \
'' u 1:3 w l axes x1y1 ti "optimization output" lc rgb "green", \
'' u 1:4 w l axes x1y2 ti "Error between stdRef and opt" lc rgb "blue"
set output
### end of code