Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot: generate two different output files

Tags:

gnuplot

I'm using gnuplot to print a chart. I want to print this chart once with a normal scale and once with a log scale.

When I print the image with a logscale I want to execute the following code:

set yrange[1:500]
set logscale y
set ytics (100, 200, 400) nomirror

However, when I want to print the image with a normal scale, I want to use the following code:

set yrange[1:350]
set ytics (100, 200, 300) nomirror

At the moment, I comment these command out if I want to print a specific version. However, I'm asking myself if there is a better option to do this. Maybe an if-condition?

The same question applies for the output file. At the moment I'm doing it like this:

set output '| ps2pdf - "plot.pdf"'

and if I print the log scale file, I just change the output name. However, I would prefer to generate both images at the same time. How can I achieve that?

like image 276
RoflcoptrException Avatar asked Mar 23 '23 08:03

RoflcoptrException


1 Answers

How about:

set terminal pdfcairo

set output 'normalPlot.pdf'

set yrange[1:350]
set ytics (100, 200, 300) nomirror
plot 'data.dat'

set output 'logPlot.pdf'

set yrange[1:500]
set logscale y
set ytics (100, 200, 400) nomirror
replot

It's fine to have two outputs at different points in the same script.

I also suggest using the pdf or pdfcairo terminals directly rather than converting, unless you have a good reason for doing so.

like image 185
andyras Avatar answered Mar 31 '23 09:03

andyras