Department of Physics and Astronomy


IDL Tutorial: Generating Hardcopy of Plots

There are many different ways to produce plots in a format other than onto the IDL graphics window. This tutorial describes one (of many) ways to generate hardcopy from a postscript printer. The assumption is that you are on a Windows-based machine, but I'll include some info to help you plot from Linux, below.

The procedure comprises the following steps:

  1. First, make a script to generate a plot on the graphics window. Tweak it until you like the plot.

  2. Set up IDL to plot an encapsulated postscript file of some chosen name. Encapsulated postscript files offer the advantage that they can be included in documents (like your final project paper), printed, and converted into other formats, all pretty easily.

  3. Run your plotting script.

  4. Close the postscript file.

  5. Then, use a postscript viewer to look at it and print it, or, if one is not available, embed the plot in a word processing document. MS Word knows how to read postscript “images.”

I'm going to assume that you have a script containing a list of commands that would ordinarily plot to the IDL window. Suppose this script is called plotmydata.pro. Here is a set of commands to generate an encapsulated postscript file.

olddevice = !d.name ; store the current device name in a variable
set_plot, 'PS'
; switch to the postscript device
device, /encapsulated, file='myplot.eps'
; specify some details, give the file a name
@plotmydata.pro
; run the plotting script
device, /close
; close the file
set_plot, olddevice
; go back to the graphics device

Now, under Windows, the easiest way to view and print the file is to use GSView, which is probably not installed on the computer you're using. Don't panic. You can also view the file in a blank Word document. Open such a blank word document, and Insert -> Picture -> From File... and selected your myplot.eps file (or whatever you called it.) Print it, save it, stretch it, annotate it, do whatever you like to your new plot.

You have more options under Linux, but your best bet is to use a program called "gv." At a terminal command prompt, try gv myplot.eps.


Back to Index

Next Tutorial


Last modified by Jack Gallimore.