gpt4 book ai didi

bash - 未能使用 gnuplot 将三个图形合并在一个图中

转载 作者:行者123 更新时间:2023-12-04 10:46:30 24 4
gpt4 key购买 nike

我正在尝试运行 gnuplot获取一个图中所有列的图形。

我有一个四列的输出文件转储。

1)Input
2)Ref Output
3)Optimization Output
4)Error between ref and opt output

我正在尝试使用以下内容运行命令以获取一张图,但我得到的是三张图而不是一张图。

我尝试将相同的名称 *.png 用于所有三个graps,但这不起作用。

你能指导我将所有三个图形合并为一个图形吗?

我的 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

关于bash - 未能使用 gnuplot 将三个图形合并在一个图中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59681122/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com