How to output a file in gnuplot multiplot mode?

2020-07-08 07:25发布

问题:

I am plotting graphs in gnuplot (version 4.6 patchlevel 5) multiplot mode, which are being updated using reread.

set multiplot layout 3, 3
do for [planeIter=4:10:3] for [ringIter=0:20:10] {
    plot for [quadIter=0:90:30] path/to/file \
    using 1:(column(1 + planeIter + ringIter + quadIter)) notitle
}
pause 10
reread

Previously, I have outputted png files using:

set terminal pngcairo dashed enhanced
plot path/to/file using 1:2
set output 'foo.png'

But I haven't been able to find how to output a file of the latest multiplot screen. Please would you tell me how I could do this? Thank you.

回答1:

As gnuplot will tell you:

you can't change the output in multiplot mode

So make sure you set it beforehand:

set terminal pngcairo dashed enhanced
set output 'foo.png'
set multiplot layout 3, 3
do for [planeIter=4:10:3] for [ringIter=0:20:10] {
    plot for [quadIter=0:90:30] path/to/file \
    using 1:(column(1 + planeIter + ringIter + quadIter)) notitle
}
unset multiplot
unset output
pause 10
reread

This is currently an infinite loop, so I assume that you are interrupting it manually. The unset lines will cause the output to be flushed, so your final image will be written.