Coyote's Guide to IDL Programming

Multiple PostScript Plots

QUESTION: Can I create multiple PostScript plots in IDL?

ANSWER: Yes. Creating multiple PostScript plots is done exactly the same way it's done on the display. See, for example, the Small Multiples Plot in the Coyote Plot Gallery for an example of how this is done.

The only trick to creating multiple PostScript plots is knowing how to set up the PostScript output window. If the output window has the same aspect ratio as the display window, then your output should be identical (or nearly so) to the output on the display. (See the programming tip "How can I make my PostScript output look like my display output?").

You can use !P.MULTI to set up multiple plots on the PostScript page. For example, to plot 4 plots in 2 rows and 2 columns in column order, type this:

   SET_PLOT, 'PS'
   DEVICE, XSIZE=5, YSIZE=5, /INCHES
   !P.MULTI=[0, 2, 2, 0, 1]
   cgPLOT, data1
   cgPLOT, data2
   cgPLOT, data3
   cgPLOT, data4

Multiple PostScript Pages

If you want to have multiple pages of PostScript output, it is as simple as typing the same commands you use to output to the display. Each IDL command that would erase the current display window (such as PLOT, SURFACE, CONTOUR, etc.) creates another page of PostScript output in the PostScript file. Each IDL command that doesn't erase the display (such as PLOTS, XYOUTS, TV, TVSCL, etc.) goes onto the same PostScript page. You can use the ERASE command to go to the next PostScript page if you like.

Here is an example where I put a plot on the first page and an image on the second page of a PostScript file.

   SET_PLOT, 'PS'
   DEVICE, XSIZE=5, YSIZE=5, /INCHES
   cgPLOT, data1
   cgOPLOT, data2
   ERASE
   cgIMAGE, image

Notice that the cgOPLOT command puts its output on the first PostScript page and not the second.

Google
 
Web Coyote's Guide to IDL Programming