Fanning Software Consulting

An Intuitive Surface Command

QUESTION: OK, I agree the Surface command is lame, and I like your cgSurf alternative command for doing traditional surface plots. But even cgSurf can't avoid the inherent limitations of the Surface command. The Surface command ain't 3D, bro!

And I've tried the ITTVIS-supplied alternatives, iSurface and the IDL 8 Surface function, but what are those people smoking, man? I type iSurface and I get an ugly yellow surface with the Z axis in the wrong friggin' place and the damn thing slides all over when I go to rotate it! The IDL 8 Surface function isn't much better, although at least it stays put when I touch it and the surface stays in the resized window. But why such a low-level shaded surface plot? And in yellow for goodness sake! Don't those people know what I want to do with a surface? Are these the best defaults they can come up with?

   IDL> data = cgDeomData(2)
   IDL> iSurface, data
   IDL> s = Surface(data)
The new ITTVIS supplied Surface alternatives.
The default surface view for iSurface on the left and the new IDL 8 Surface function on the right.
 

ANSWER: I hear you, man. I feel your pain.

You may be interested in the alternative surface command cgSurface. This command is meant to work like you do and it uses most of the same keywords you are already familiar with from using the Surface and cgSurf commands. In fact, it is meant to work from the IDL command line like the traditional Surface command, except for providing the additional functionality offered by the object graphics system in IDL. In particular, the surface can be rotated freely about all three surface axes with the mouse. The surface can be rotated by clicking anywhere on the surface. The surface can be moved or translated by clicking on any axis. The title of the plot can also be moved or translated by clicking on it. This gives you great flexibility in how the surface is displayed.

Here is what the default surface looks like both as a wire-frame surface and as a shaded surface.

   IDL> data = cgDeomData(2)
   IDL> cgSurface, data
   IDL> cgSurface, data, /Shaded

Notice that a significant benefit of using this command is that it doesn't ask you bothersome questions when you close the surface window. This in itself is more than enough reason to prefer it to the IDL 8 Surface function!

Default cgSurface commands
The default wire-mesh and shaded surface versions of cgSurface.
 

Elevation shading can be accomplished just by setting the Elevation_Shading keyword. By default, the program will use the current color table for the shading parameters, or you can specify which color table you would like to use.

   IDL> data = cgDeomData(2)
   IDL> LoadCT, 33
   IDL> cgSurface, data, /Elevation_Shading
   IDL> cgSurface, data, /Shaded, /Elevation_Shading, CTable=4, /Brewer
Default cgSurface shaded surface commands
The surface can be shaded according to elevation.
 

Program colors, including Brewer colors and color tables, and other surface properties can be selected interactively via pull-down menu selections.

Program properties via pull-down menus. cgPickColorName program to select program colors.
Surface properties can be changed via pull-down menus.
 

The surface is illuminated with four different light sources. A light controler is available from the Properties pull-down menu to allow you to control the intensity and color of each light, as well as turn each light on or off. Varying the light colors and intensity can cause the surface to be illuminated in interesting and informative ways.

The surface uses four lights for illumination
The surface uses four lights for illumination.
 

The surface can be saved in a variety of image file formats, including PostScript.

The can be save in several different file formats
The can be save in several different file formats, including PostScript.
 

An 2D or true-color image can be added to the surface as a texture map. In the two figures below, the ZScale keyword is use to reduce the Z axis scaling to half its original value to better see the textured mapped surface.

   IDL> cgSurface, data, ZScale=0.5, Texture_Image=cgDeomData(7), $
          CTable=1, /Brewer, /Reverse, Title='2D Image as Texture'
   IDL> cgSurface, data, ZScale=0.5, Texture_Image=cgDeomData(16), $
          Title='True-Color Image as Texture'
2D or 3D images as texture maps.
Any 2D or true-color image can be overlaid on the surface as a texture map.
 

The Constrain_Aspect keyword will constrain the X and Y aspect ratio of the surface so that the surface maintains its shape when it is displayed.

   IDL> shapedData = Rebin(data, 41*3, 41)
   IDL> cgSurface, shapedData , /CONSTRAIN_ASPECT, /Shaded
The surface aspect ratio constrained
The surface aspect ratio can be constrained to
the actual dimensions of the surface.
 

Version of IDL used to prepare this article: IDL 7.0.1.

Last Updated: 11 March 2011