не удалось объединить три графика в одном графике с помощью gnuplot - PullRequest
2 голосов
/ 10 января 2020

Я пытаюсь запустить 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

1 Ответ

2 голосов
/ 10 января 2020

Это, наверное, то, что вы ищете. Нет необходимости в перепланировке.

Код:

### 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
...