Michal
Michal

Reputation: 21

Multifile output in gnuplot without replot

I want to make a gnuplot script template that would produce eps and png outputs. The goal is that when I want to make a new plot I just copy the template, set formats, labels etc., and plot what I need to plot.

The easy way is:

set terminal postscript eps
set output 'output.eps'
plot sin(x)
set output

set terminal pngcairo
set output 'output.png'
replot
set output

However when using multiplot, the replot command only replots last plot, so I would have to reenter mutliplot for the second output and make additional changes that I would prefer to avoid.

What I would like to achieve would be something like this, in gnuplot pseudocode:

set terminal 1 postscript eps
set output 1 'output.eps'
set terminal 2 pngcairo
set output 2 'output.png'

plot ...

set output 1
set output 2

So that both output files are produced in parallel, and the only thing that I would have to edit are lines between opening and closing output files.

I could make a bash script to make it work the way I want, but I prefer to handle it within the gnuplot script, so that it would be portable, and in single file.

Is there a way to do it like this?

Upvotes: 2

Views: 295

Answers (1)

Joce
Joce

Reputation: 2342

Consider a loop:

do for [FILETYPE in "png eps"] {
 set output "plot.".FILETYPE
 set term FILETYPE
 plot x**2
 set output
}

Upvotes: 2

Related Questions