Coyote Graphics Routines

Date: Fri Mar 27 12:14:20 2015

single page | use frames     summary     class     fields     routine details     file attributes


top cgPS_Open

Utilities, Graphics

cgPS_Open [, filename] [, /CANCEL] [, CHARSIZE=float] [, DEFAULT_THICKNESS=integer] [, /DEJAVUSANS] [, FILENAME=string] [, FONT=integer] [, /ENCAPSULATED] [, /GUI] [, KEYWORDS=structure] [, /LANDSCAPE] [, /NOMATCH] [, /QUIET] [, SCALE_FACTOR=float] [, TT_FONT=string] [, _REF_EXTRA=_REF_EXTRA]

The purpose of cgPS_Open and cgPS_Close is to make it easy to set-up and close a PostScript file. These programs are used extensively in all Coyote Graphics routines.

If ImageMagick is installed on your computer, you can easily convert PostScript output to GIF, JPEG, PNG, and TIFF raster output. If Ghostscript is installed you can convert PostScript output to PDF files. See the appropriate keywords to cgPS_Close.

When cgPS_Open is called, the current graphics device is set to "PS" (the PostScript device). When cgPS_Close is called the current graphics device is returned to the device in effect when cgPS_Open was called.

cgPS_Open uses the current display window as a template for the Postscript file. Thus, if the display window is wider than it is higher, output is in Landscape mode. To set the size of the PostScript "window" yourself, be sure to set the NOMATCH keyword to 1.

To display surface plots correctly the FONT keyword should be set to 1. Otherwise, the default font is 0, or hardware fonts when outputting to PostScript.

You can easily configure any modifications you like for your PostScript output by setting fields in the plot and axis system variables (!P, !X, !Y, and !Z). The modifications currently made by default in this program are these:

!P.Thick = 3 !P.CharThick = 3 !X.Thick = 3 !Y.Thick = 3 !Z.Thick = 3 !P.Font = 0
The !P.Charsize variable is set differently on Windows computers, and depending on whether !P.MULTI is being used. On Windows the default is 1.25, or 1.00 for multiple plots. On other computers, the default is 1.5, or 1.25 for multiple plots. If true-type fonts are being used (FONT=1), the default is 1.5, or 1.25 for multiple plots.

The cgPS_Open program contains the common block, _$FSC_PS_START_. See the FSC_PS_SETUP__DEFINE program in the Coyote Library for its definition.


filename in optional type=string

The name of the PostScript file to be created. This can also be the name of a raster file (e.g., PNG, JPEG, TIFF, PDF, etc.) that you would like to have created from a PostScript intermediate file. This requires that ImageMagick is installed correctly on your machine. If you choose this kind of filename, the intermediate PostScript file is automatically deleted.


CANCEL out optional type=boolean default=0

An output keyword that is set to 1 if the user cancelled from PS_Config. Otherwise, set to 0.

CHARSIZE in optional type=float

If this keyword is set, the !P.Charsize variable is set to this value until cgPS_Close is called.

DEFAULT_THICKNESS in optional type=integer default=3

Sets the following system variables to this value while creating PostScript output: !P.Thick, !P.CharThick, !X.Thick, !Y.Thick, !Z.Thick. These variables are returned to their original values by cgPS_Close. A system variable is set to this value only if it currently contains the IDL default value of 0.0. If it is set to anything else, this default thickness value is ignored.

DEJAVUSANS in optional type=boolean default=0

Set this keyword to select the DejaVuSans true-type font for PostScript output. This option is ONLY available in IDL 8.2 or higher and/or you have installed the DejaVuSans true-type font in your font directory.

FILENAME in optional type=string

The name of the PostScript file created. An alternative, and older, way of setting the filename parameter.

FONT in optional type=integer default=0

Set this to the type of font you want. A -1 selects Hershey fonts, a 0 selects hardware fonts (Helvetica, normally), and a 1 selects a True-Type font. Set to 0 by default.

ENCAPSULATED in optional type=boolean default=0

Set this keyword to produce encapsulated PostScript output.

GUI in optional type=boolean default=0

The default behavior is to use cgPS_Config to configure the PostScript device silently. If you wish to allow the user to interatively configure the PostScript device, set this keyword.

KEYWORDS out optional type=structure

This output keyword contains the keyword structure returned from PS_Config.

LANDSCAPE in optional type=boolean default=0

Set this keyword to produce landscape PostScript output.

NOMATCH in optional type=boolean default=0

Normally, cgPS_Open will try to "match" the aspect ratio of the PostScript file "window" to the current display window. If this keyword is set, then this doesn't occur, giving the user the option of specifying the size and offsets of the PostScript window directly though appropriate keywords.

QUIET in optional type=boolean default=0

If set, informational messages are not set.

SCALE_FACTOR in optional type=float default=1.0

Set this to the PostScript scale factor. By default: 1.

TT_FONT in optional type=string

The name of a true-type font to use. Using this keyword sets Font to 1.

_REF_EXTRA in optional

Any keyword appropriate for the PostScript configuration program cgPS_Config, from the Coyote Library can be used with cgPS_Open.


To create a line plot in a PostScript file named and also create a PNG file named lineplot.png for display in a browser, type these commands:

cgPS_Open, '' cgPlot, Findgen(11), COLOR='navy', /NODATA, XTITLE='Time', YTITLE='Signal' cgPlot, Findgen(11), COLOR='indian red', /OVERPLOT cgPlot, Findgen(11), COLOR='olive', PSYM=2, /OVERPLOT cgPS_Close, /PNG
Or, alternatively, without also creating a PostScript file, like this. Simply pass cgPS_Open the name of the raster file you want to create:
cgPS_Open, 'lineplot.png' cgPlot, Findgen(11), COLOR='navy', /NODATA, XTITLE='Time', YTITLE='Signal' cgPlot, Findgen(11), COLOR='indian red', /OVERPLOT cgPlot, Findgen(11), COLOR='olive', PSYM=2, /OVERPLOT cgPS_Close

Author information



David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: Coyote's Guide to IDL Programming:


Copyright (c) 2008-2014, Fanning Software Consulting, Inc.


Change History:

Written by: David W. Fanning, 20 May 2008. Slight modification to allow filenames with spaces in them. Added NoMatch keyword. 17 March 2009. DWF. Added a number of keywords to make these commands more configurable. 19 March 2009. DWF. Only set thickness system variables if starting system variables are set to their default values (namely, 0). This allows users to set their own system variables before they call PS_START, rather than after. 23 March 2009. DWF. Moved PS_END to its own file to allow the IDLExBr_Assistant to work properly. 7 April 2009. DWF. Modified to allow PostScript page type to be stored for future processing with cgFixPS. 9 August 2009. DWF. Added NoFix keyword to PS_END calls to repair previous, but unused set-ups. 1 Nov 2010. DWF. Added Charsize keyword to PS_START. 14 Nov 2010. DWF. Changed the way default character sizes are set. 19 Nov 2010. DWF. Added CANCEL and KEYWORDS output keywords. 16 Jan 2011. DWF. Changes to handle inability to create raster files from PS encapsulated files in landscape mode. 26 Aug 2011. DWF. The SCALE_FACTOR is called at the time the PostScript file is opened to avoid problems with the bounding box not being set to the correct values. 26 October 2011. DWF. Created a DEFAULT_THICKNESS keyword to set the default thicknesses of PostScript system variables. 14 Dec 2011. DWF. Moved the true-type font set-up to *after* changing the graphics device to PostScript. 10 Jan 2012. DWF. Added DejaVuSans keyword to allow this true-type font to be used in PostScript Output. 21 Dec 2012. DWF. Modified so that the PostScript device can keep a consistent interface when using True-Type fonts. Requires using cgSet_TTFont to select True-Type fonts. 22 May 2013. DWF. Changed name to cgPS_Open from PS_Start. 4 November 2013. DWF. Retired PS_Start. Added ability to specify the name of the output raster file desired as the filename. If this is done, and ImageMagick is installed, the PostScript intermediate file is deleted and the raster file is created automatically without setting a raster output keyword on cgPS_Close. 29 Nov 2013. DWF. Moved the check for Charsize to after setting to the PostScript device. 14 Jan 2014. DWF. The program wasn't picking up default values from cgWindow_GetDefs. 22 Jan 2014. DWF. Modified the program so that the PostScript file location is printed only if the PostScript file is being retrained. 17 March 2014. DWF. Fixed a problem that prevented setting FONT=0 when setting cgPS_Open parameters with cgControl. 3 Mar 2015. DWF.

File attributes

Modification date: Fri Mar 27 11:07:36 2015
Lines: 374
Docformat: rst rst