Printing Graphics Output Files

For Direct Graphics printer and plotter devices (e.g., PCL, PostScript, and HP-GL), IDL creates a file containing output commands. This file can be sent to the printer via the normal methods provided by the local operating system. When attempting to output the file before exiting IDL, the user must be sure that the graphics output file is complete. For example, the following IDL commands (executed under UNIX) will not produce the desired result:

SET_PLOT,'PS' 
PLOT,x,y 
SPAWN,'lpr idl.ps' 

These commands fail because the attempt to print the file is premature—the file is still open within IDL and is not yet complete.

Note
Use of SET_PLOT and the direct graphics commands is not required when creating graphical output files or printing to a printer using the iTools or other object-graphics routines.

The following lines of code are an IDL procedure called OUTPUT_PLOT which closes the current graphics file and sends it to the printer. This routine assumes that the graphics output file is named idl.xxx, where xxx represents the name of the graphics driver. For example, PostScript output file is assumed to be idl.ps. It also assumes that the graphics output to be printed is from the current graphics device, as selected with SET_PLOT.

; Close the current graphics file, and print it. If the  
; New_file parameter is present, rename the file to the given  
; name so it won't be overwritten: 
Pro OUTPUT_PLOT, New_file 
; Close current graphics file: 
DEVICE,/CLOSE 
; Build the default output file name by using the idl name for  
; the current device (!D.NAME): 
file = 'idl.' + STRLOWCASE(!D.NAME) 
; Build shell commands to send file to the printer.  
; You will probably have to change this command in accordance  
; with local usage: 
cmd = 'lpr ' + file 
; Concatenate rename command if new file specified: 
IF N_ELEMENTS(New_file) GT 0 THEN $ 
   cmd = cmd + '; mv' + file + ' ' + New_file 
; Issue shell commands to print/rename file: 
SPAWN, cmd 
END 

The call to DEVICE causes IDL to finish the file and close it, which makes it available for printing.

Setting Up The Printer

In order for IDL generated output files to work properly with printers and plotters, it is necessary for the device to be configured properly. This usually involves configuring both the device hardware and the operating system printing software. When setting up your system, keep the following points in mind:

Setting Up Printers Under UNIX

Printers are configured in the /etc/printcap file. This file describes to the system which printers are connected to it, the characteristics of each printer, and how the printer port should be configured. Managing the printcap file is usually discussed in the system management documentation supplied with the system by the manufacturer.

Positioning Graphics Output

The difference between the XOFFSET and YOFFSET keywords to the DEVICE procedure, and the higher level plot positioning keywords and system variables (discussed in Graphics Keywords) can lead to confusion. A common misunderstanding is to attempt to use the DEVICE procedure "offset" and "size" keywords multiple times in an attempt to produce multiple plots on a single output page.

The DEVICE keywords are intended to specify the size and position of the entire output area on the page, not to move the plotting region for multiple plots. The driver does not monitor their values continuously, but only when initializing a new page or ejecting the current one.

The proper way to produce multiple plots is to use the high level positioning abilities. The !P.MULTI, !P.POSITION, and !P.REGION system variables can be used to position individual plots on the page. The plotting routines also accept the POSITION, MARGIN and REGION keywords.

Image Background Color

Graphical output that is displayed with a black background on a monitor frequently look better if the background is changed to white when printed on white paper. This is easily done using the BACKGROUND graphics keyword or (if the only values displayed in black are in the background) with a statement like:

a(WHERE(a EQ 0B)) = 255B