Coyote Graphics Routines

Date: Thu May 17 08:12:58 2012

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

.\

cgplot.pro


top cgPlot

Graphics

cgPlot, x [, y] [, /ADDCMD] [, ASPECT=float] [, AXISCOLOR=string/integer] [, AXESCOLOR=string/integer] [, BACKGROUND=string/integer] [, CHARSIZE=float] [, COLOR=string/integer] [, FONT=integer] [, /ISOTROPIC] [, LAYOUT=intarr(3)] [, /NODATA] [, /NOERASE] [, OUTFILENAME=string] [, OUTPUT=string] [, /OVERPLOT] [, POSITION=vector] [, PSYM=integer] [, SYMCOLOR=string/integer] [, SYMSIZE=float] [, /TRADITIONAL] [, /WINDOW] [, _REF_EXTRA=any]

The purpose of cgPlot is to create a wrapper for the traditional IDL graphics command, Plot. The primary purpose of this is to create plot commands that work and look identically both on the display and in PostScript files.

Program default colors will depend on the IDL graphics window. If no windows are currently open when the program is called, cgDisplay is used to create a window.

The program requires the Coyote Library to be installed on your machine.

Parameters

x in required type=any

If X is provided without Y, a vector representing the dependent values to be plotted If both X and Y are provided, X is the independent parameter and Y is the dependent parameter to be plotted.

y in optional type=any

A vector representing the dependent values to be plotted.

Keywords

ADDCMD in optional type=boolean default=0

Set this keyword to add the command to the resizeable graphics window cgWindow.

ASPECT in optional type=float default=none

Set this keyword to a floating point ratio that represents the aspect ratio (ysize/xsize) of the resulting plot. The plot position may change as a result of setting this keyword. Note that Aspect cannot be used when plotting with !P.MULTI.

AXISCOLOR in optional type=string/integer default=opposite

If this keyword is a string, the name of the axis color. Otherwise, the keyword is assumed to be a color index into the current color table.

AXESCOLOR in optional type=string/integer

Provisions for bad spellers.

BACKGROUND in optional type=string/integer default=background

If this keyword is a string, the name of the background color. Otherwise, the keyword is assumed to be a color index into the current color table.

CHARSIZE in optional type=float default=cgDefCharSize()

The character size for axes annotations. Uses cgDefCharSize to select default character size, unless !P.Charsize is set, in which case !P.Charsize is always used.

COLOR in optional type=string/integer default=black

If this keyword is a string, the name of the data color. By default, 'black'. Color names are those used with cgColor. Otherwise, the keyword is assumed to be a color index into the current color table.

FONT in optional type=integer default=!P.Font

The type of font desired for axis annotation.

ISOTROPIC in optional type=boolean default=0

A short-hand way of setting the Aspect keyword to 1.

LAYOUT in optional type=intarr(3)

This keyword specifies a grid with a graphics window and determines where the graphic should appear. The syntax of LAYOUT is three numbers: [ncolumns, nrows, location]. The grid is determined by the number of columns (ncolumns) by the number of rows (nrows). The location of the graphic is determined by the third number. The grid numbering starts in the upper left (1) and goes sequentually by column and then by row.

NODATA in optional type=boolean default=0

Set this keyword to draw axes, but no data.

NOERASE in optional type=boolean default=0

Set this keyword to draw the plot without erasing the display first.

OUTFILENAME in optional type=string

If the Output keyword is set, the user will be asked to supply an output filename, unless this keyword is set to a non-null string. In that case, the value of this keyword will be used as the filename and there will be no dialog presented to the user.

OUTPUT in optional type=string

Set this keyword to the type of output desired. Possible values are these: 'PS' - PostScript file 'EPS' - Encapsulated PostScript file 'PDF' - PDF file 'BMP' - BMP raster file 'GIF' - GIF raster file 'JPEG' - JPEG raster file 'PNG' - PNG raster file 'TIFF' - TIFF raster file Or, you can simply set this keyword to the name of the output file, and the type of file desired will be determined by the file extension. If you use this option, the user will not be prompted to supply the name of the output file.

All raster file output is created through PostScript intermediate files (the PostScript files will be deleted), so ImageMagick and Ghostview MUST be installed to produce anything other than PostScript output. (See cgPS2PDF and PS_END for details.) And also note that you should NOT use this keyword when doing multiple plots. The keyword is to be used as a convenient way to get PostScript or raster output for a single graphics command. Output parameters can be set with cgWindow_SetDefs.

OVERPLOT in optional type=boolean default=0

Set this keyword if you wish to overplot data on an already exisiting set of axes. It is like calling the IDL OPLOT command.

POSITION in optional type=vector

The usual four-element position vector for the Plot comamnd. Only monitored and possibly set if the Aspect keyword is used.

PSYM in optional type=integer

Any normal IDL PSYM values, plus any value supported by the Coyote Library routine SYMCAT. An integer between 0 and 46.

SYMCOLOR in optional type=string/integer default=black

If this keyword is a string, the name of the symbol color. By default, 'black'. Otherwise, the keyword is assumed to be a color index into the current color table.

SYMSIZE in optional type=float default=1.0

The symbol size.

TRADITIONAL in optional type=boolean default=0

If this keyword is set, the traditional color scheme of a black background for graphics windows on the display is used and PostScript files always use a white background.

WINDOW in optional type=boolean default=0

Set this keyword to replace all the commands in a current cgWindow or to create a new cgWindow for displaying this command.

_REF_EXTRA in optional type=any

Any keyword appropriate for the IDL Plot command is allowed in the program.

Examples

Use as you would use the IDL PLOT command: cgPlot, Findgen(11) cgPlot, Findgen(11), Aspect=1.0 cgPlot, Findgen(11), Color='olive', AxisColor='red', Thick=2 cgPlot, Findgen(11), Color='blue', SymColor='red', PSym=-16

Author information

Author:

FANNING SOFTWARE CONSULTING: David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com

Copyright:

Copyright (c) 2010-2012, Fanning Software Consulting, Inc.

History:

Change History: Written, 12 November 2010. DWF. Added SYMCOLOR keyword, and allow all 46 symbols from SYMCAT. 15 November 2010. DWF. Added NODATA keyword. 15 November 2010. DWF. Now setting decomposition state by calling SetDecomposedState. 16 November 2010. DWF. Final color table restoration skipped in Z-graphics buffer. 17 November 2010. DWF. Fixed a problem with overplotting with symbols. 17 November 2010. DWF. Background keyword now applies in PostScript file as well. 17 November 2010. DWF. Many changes after BACKGROUND changes to get !P.MULTI working again! 18 November 2010. DWF. Fixed a small problem with the OVERPLOT keyword. 18 Nov 2010. DWF. Changes so that color inputs don't change type. 23 Nov 2010. DWF. Added WINDOW keyword to allow graphic to be displayed in a resizable graphics window. 8 Dec 2010. DWF Modifications to allow cgPlot to be drop-in replacement for old PLOT commands in indexed color mode. 24 Dec 2010. DWF. Previous changes introduced problems with OVERPLOT that have now been fixed. 28 Dec 2010. DWF. Set NOERASE keyword from !P.NoErase system variable when appropriate. 28 Dec 2010. DWF. Additional problems with NOERASE discovered and solved. 29 Dec 2010. DWF. In some cases, I was turning BYTE values to strings without converting to INTEGERS first. 30 Dec 2010. DWF. Selecting character size now with cgDefCharSize. 11 Jan 2011. DWF. Moved setting to decomposed color before color selection process to avoid PostScript background problems when passed 24-bit color integers. 12 Jan 2011. DWF. Changed _EXTRA to _REF_EXTRA on procedure definition statement to be able to return plot keywords such as XGET_TICKS. 13 Jan 2011. DWF. Added SYMSIZE keyword. 16 Jan 2011. DWF. Fixed a problem in which I assumed the background color was a string. 18 Jan 2011. DWF. Added ADDCMD keyword. 26 Jan 2011. DWF. Added LAYOUT keyword. 28 Jan 2011. DWF. Made a modification that allows THICK and COLOR keywords apply to symbols, too. 24 Feb 2011. DWF. Modified error handler to restore the entry decomposition state if there is an error. 17 March 2011. DWF Somehow I had gotten independent and dependent data reversed in the code. Put right. 16 May 2011. DWF. Allowed ASPECT (and /ISOTROPIC) to take into account input POSITION. 15 June 2011. Jeremy Bailin. Updated the BACKGROUND color selection from lessons learned in 27 Oct 2011 cgContour corrections. 27 Oct 2011. DWF. Added the ability to send the output directly to a file via the OUTPUT keyword. 9 Dec 2011, DWF. PostScript, PDF, and Imagemagick parameters can now be tailored with cgWindow_SetDefs. 14 Dec 2011. DWF. Modified to use cgDefaultColor for default color selection. 24 Dec 2011. DWF. Over-zealous use of _STRICT_EXTRA when overplotting resulted in errors. Now use _EXTRA. 1 Jan 2012. DWF. Changes to allow better default colors, based on changes to cgColor and cgDefaultColor. 1 Feb 2012. DWF. Now allowing the user to draw in the "background" color, if the COLOR or AXISCOLOR is "BACKGROUND". 19 March 2012. DWF. Scalar input parameters are changed to 1-element vectors to avoid annoying error messages from PLOT. 6 April 2012. DWF.

File attributes

Modification date: Thu Apr 19 17:07:20 2012
Lines: 655
Docformat: rst rst