printing multipage postscript files

Ben Abbott bpabbott at mac.com
Wed Jun 3 04:53:20 CDT 2009


On Jun 3, 2009, at 5:04 AM, Petr Mikulik wrote:

> In Octave 2.x, printing many drawings into one multipage postscript  
> file
> was very easy:
> 	gset term post; gset out 'a.ps'
> 	plot(1:10)
> 	plot(2:20) # many plots from simulations, one plot per page
> 	gset out; gset term x11
>
> (Note that multipage pdf files or animated gifs were also possible  
> using
> gset term pdf or gset term gif animate.)
>
> In Matlab, it is achieved in a more complicated way which requires  
> "print"
> command after each plot:
> 	plot(1:10)
> 	print a.ps -dps
> 	plot(2:20)
> 	print a.ps -dps -dappend
>
> which actually needs to be written in this way if the same script  
> generates
> graphs for screen and/or printer:
> 	print=1;
>        plot(1:10)
>        if (print) print a.ps -dps; endif
>        plot(2:20)
>        if (print) print a.ps -dps -dappend; endif
>
> How to achieve this in Octave 3.x where gset is no longer possible?
> Gnuplot does not support concatenation of output into one file.
>
> It seems to me that the "-dappend" option could be easily  
> implemented in
> Octave this way (requires ghostcript and creation of two temporary  
> files):
>    print a.ps -dps -dappend
> =>
>    drawnow('/tmp/tmp1.ps')
>    gs -dNOPAUSE -sDEVICE=pswrite -sOutputFile=/tmp/tmp2.ps \
> 	 a.ps tmp1.ps -c quit
>    mv /tmp/tmp2.ps a.ps
>
> If ghostscript is not found, then the last plot will overwrite the  
> file,
> i.e.
>   mv /tmp/tmp1.ps a.ps
>
> On unixes, ghostscript is always called "gs", thus there will be no  
> problem.
> On Windows, these names can be rather different ("gswinc"?).
> On Mac?
>
> Could the "-dappend" functionality by added?

Petr,

As Octave's print command already relies upon ghostscript, such  
functionality can be added without to much difficulty.

Regarding Mac OSX, it is another Unix variant, so what works on other  
unixes can work there as well.

I'll take a look at this over the next few days.

Ben



More information about the Bug-octave mailing list