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?

share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
    
Thanks for the hint. And also thank for the hint how I could generate two output files. However, no I have to duplicate my whole plot code. Is there any way to avoid this? – RoflcoptrException Jun 29 '13 at 19:08
    
Yes, there is! The replot command will plot the same data as the previous plot command. (I meant to use that in my example the first time--I have edited it.) – andyras Jun 29 '13 at 19:15
    
cool thanks a lot! now I have to only figure out how to install pdfcairo on my mac and then everything is done :) – RoflcoptrException Jun 29 '13 at 19:20
    
Ok another minor issue :) What if the last plot is a multiplot? :) – RoflcoptrException Jun 29 '13 at 19:38
    
@RoflcoptrException For multiplot mode you can't use replot but you could put the common code into one file and load it with load 'file.gp' from the main file. – Christoph Aug 5 '13 at 12:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.