Coyote Graphics Routines

Date: Fri Mar 27 12:14:20 2015

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

.\

cgsurf.pro


top cgSurf

Graphics

cgSurf, data [, x] [, y] [, /ADDCMD] [, AXISCOLOR=string/integer] [, BACKGROUND=string/integer] [, BOTTOM=string/integer] [, CHARSIZE=float] [, COLOR=string/integer] [, /ELEVATION_SHADING] [, FONT=integer] [, LAYOUT=intarr(3)] [, /NOERASE] [, OUTFILENAME=string] [, OUTPUT=string] [, PALETTE=byte] [, ROTX=float] [, ROTZ=float] [, /SHADED] [, SHADES=byte] [, SKIRT=any] [, TITLE=string] [, /TRADITIONAL] [, TLOCATION=float] [, TSIZE=float] [, TSPACE=float] [, /WINDOW] [, XTITLE=string] [, YTITLE=string] [, ZTITLE=string] [, _Ref_Extra=any]

The purpose of cgSurf is to create a wrapper for the traditional IDL graphics commands, Surface and Shade_Surf. The primary purpose of this is to create surface commands that work and look identically both on the display and in PostScript files.

Parameters

data in required type=any

A two-dimensional array of data to be displayed.

x in optional type=any

A vector or two-dimensional array specifying the X coordinates of the surface grid.

y in optional type=any

A vector or two-dimensional array specifying the Y coordinates of the surface grid.

Keywords

ADDCMD in optional type=boolean default=0

Set this keyword to add the command to an cgWindow. Setting this keyword automatically sets the WINDOW keyword, but the command does not erase the graphics window as it would normally.

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 hidden 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.

BOTTOM in optional type=string/integer default=black

If this keyword is a string, the name of the bottom color. By default, same as COLOR. Otherwise, the keyword is assumed to be a color index into the current color table.

CHARSIZE in optional type=float default=cgDefCharSize*1.25

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

COLOR in optional type=string/integer default=blu6

If this keyword is a string, the name of the data color. By default, "BLU6". Otherwise, the keyword is assumed to be a color index into the current color table.

ELEVATION_SHADING in optional type=boolean default=0

Set this keyword to put elevation shading into effect for the surface.

FONT in optional type=integer default=-1

The type of font desired. If undefined, and the current graphics device is PostScript, the FONT keyword will be set to 1, indicating true-type fonts. The FONT keyword must be set to -1 (Hershey fonts) or 1 (true-type fonts) for surface annotations to be rotated correctly in PostScript output.

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.

NOERASE in optional type=boolean default=0

Set this keyword to prevent the window from erasing the contents before displaying the surface plot.

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 cgPS_Close 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.

PALETTE in optional type=byte

Set this keyword to a 3 x N or N x 3 byte array containing the RGB color vectors to be loaded before the surface is displayed. Such vectors can be obtained, for example, from cgLoadCT with the RGB_TABLE keyword:

cgLoadCT, 33, RGB_TABLE=palette cgSurf, cgDemoData(2), PALETTE=palette, /Elevation

ROTX in optional type=float default=30

The rotation about the X axis.

ROTZ in optional type=float default=30

The rotation about the Z axis.

SHADED in optional type=boolean default=0

Set this keyword if you wish to display a shaded surface. To display shaded surfaces in a device-independent way, the shading values are confined to indices 0 to 253 with SET_SHADING, and the background color is placed in color index 254. The color table vectors are reduced to 254 elements when this happens. This all happens behind the stage, and the original color table is restore upon exit. Because I can't tell how many values SET_SHADING is using on entering the program, I just set it back to its default 256 values on exiting the program.

SHADES in optional type=byte

Set this keyword to a byte scaled 2D array of the same size as data to shade the surface with these color indices.

SKIRT in optional type=any

Set this keyword to a Z value where a skirt will be drawn for the surface.

TITLE in optional type=string

The title of the plot. It will be written "flat to the screen", rather than rotated.

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.

TLOCATION in optional type=float

A one or two element array in normalized coordinates that gives the location of the plot title. The plot is centered on this location. If one element, the X location is taken as 0.5 and the element is used as the Y location. Othersize, use [x,y]. Default is [0.5,0.9].

TSIZE in optional type=float

The character size for the title. Normally, the title character size is 1.1 times the character size of the surface annotation.

TSPACE in optional type=float

The title Y spacing. This should be a number, between 0 and 1 that is the fraction of the distance between !Y.Window[1] and !Y.Window[0] to locate the title above !Y.Window[1]. When Total(!P.MULTI) EQ 0, the default is 0.005, and it is 0.0025 otherwise. Now depreciated in favor of TLocation.

WINDOW in optional type=boolean default=0

Set this keyword to replace all the commands in the current cgWindow or to create a new cgWindow, if one doesn't currenly exist, for displaying this command. To create a new cgWindow if one currenly exists, use the cgWindow command

XSTYLE in hidden

The normal XSTYLE keyword.

XTITLE in optional type=string

The X title of the plot.

YSTYLE in hidden

The normal YSTYLE keyword.

YTITLE in optional type=string

The Y title of the plot.

ZSTYLE in hidden

The normal ZSTYLE keyword.

ZTITLE in optional type=string

The Z title of the plot.

_Ref_Extra in optional type=any

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

Examples

Use as you would use the IDL SURFACE of SHADE_SURF command:

data = Dist(200) LoadCT, 33 cgSurf, data cgSurf, data, Shades=BytScl(data) cgSurf, data, /Shaded cgSurf, data, /Shaded, Shades=BytScl(data)

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-2013, Fanning Software Consulting, Inc.

History:

Change History:

Written, 13 November 2010. DWF. Now setting decomposition state by calling cgSetColorState. 16 November 2010. DWF. Added TSIZE and TSPACE keywords to treak title size and placement, as necessary. 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. Changes so that color variables don't change type. 23 Nov 2010. DWF. Added ELEVATION_SHADING keyword. 26 Nov 2010. DWF. I had keyword conflicts with the AX and AZ rotation keywords. Now perform rotation with ROTX and ROTZ keywords. 7 Dec 2010. DWF. Added WINDOW keyword to allow graphic to be displayed in a resizable graphics window. 8 Dec 2010. DWF Changed the Title size to 1.1 times the character size of the plot. 14 Dec 2010. DWF. Modifications to allow cgSurf to be drop-in replacement for old Surface 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. Change to DECOMPOSED color was using incorrect color tables. 29 Dec 2010. DWF. In some cases, I was turning BYTE values to strings without converting to INTEGERS first. 30 Dec 2010. 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. 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. Added PALETTE keyword. 3 Feb 2011. DWF. Color table vectors must be obtained AFTER loading the color palette. 6 March 2011. DWF. Modified error handler to restore the entry decomposition state if there is an error. 17 March 2011. DWF Modified the color decomposition state to properly handle shaded surfaces in PostScript. 20 July 2011. DWF. 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 2001. DWF. Now allowing the user to draw in the "background" color, if the COLOR or AXISCOLOR is "BACKGROUND". 19 March 2012. DWF. Added the ability to use escape characters in plot titles to specify cgSymbol symbols. 27 July 2012. DWF. Lost the XTitle and YTitle keywords when doing shaded surfaces. 15 December 2012. DWF. Still had some color issues with shaded surfaces having to be done in indexed color to sort out. This appears to work now both on the display and in PostScript. 25 Jan 2013. DWF. Added the TLOCATION keyword and depreciated the TSPACE keyword. 27 May 2013. DWF. Fixed a problem with shaded surfaces that set the top color to the background color. 12 June 2013. DWF. Fixed a problem with the TITLE keyword that was resetting !P.T, even if the SAVE keyword was set. 25 Sept 2013. DWF.

File attributes

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