Supercomputing Institute Technical User Support

 

IDL: Surface and Contour Plotting

  1. Displaying a Surface
  2. Displaying a Shaded Surface
  3. Displaying a Contour
  4. Plotting with SHOW3
  5. LIVE_SURFACE

Displaying a Surface

The binary file that we will read in the following example contains an image of the Maroon Bells mountains, a group of mountains located in the Rocky Mountains of Colorado, stored as a binary integer array.  To read in the binary data we use the following command:
maroon_bells=read_binary('/usr/local/rsi/idl_5.4/idl_5.4/examples/data/surface.dat',$
data_dims=[350,450],data_type=2,endian='little')
First, view the array MARBELLS_BINARY.A as a three-dimensional, wire-mesh surface. Use the CONGRID procedure initially to resample the data set so that the mesh can be displayed at a size visible to the human eye.
1. Here resample the array size to 35 by 45, or one tenth its original size. To do this enter:
a=congrid(maroon_bells,35,45)
2. Now we are ready to visualize the mesh using the SURFACE command:
surface,a
The SURFACE command can be used to view your data from different angles. AX and AZ are plotting keywords that are used to control the SURFACE command. The keyword AX specifies the angle of rotation of the surface (in degrees towards the viewer) about the X axis. The AZ keyword specifies the rotation of the surface in degrees counterclockwise around the Z axis.
3. View the array from a different angle by entering the following command:
surface,a, ax=70, az=25

Displaying a Shaded Surface

You can also view a two-dimensional array as a light-source shaded surface.
1. First, load one of the pre-defined IDL color tables by entering:
loadct, 3
2. To view the light-source shaded surface, shown in the following, simply enter the command:
shade_surf,a
3. To look at the array from another angle, enlarge the label text, and add a title.  Again, keywords are used to control certain features of the shaded surface plot.  The AX and AZ keywords control the viewing angle, just as they did with the SURFACE command.  The CHARSIZE keyword controls the size of plotted text. The TITLE keyword was used to add the title Shaded Surface Representation.
shade_surf,a,ax=45,az=20,charsize=1.5, $
title='Shaded Surface Representation'
4. You can create a different kind of shaded surface, where the shading information is provided by the elevation of each point. Now different shading colors on the plot correspond to different elevations (the BYTSCL function scales the data values into the range of bytes). You could also specify a different array for the shading colors.
shade_surf,a,shade=bytscl(a)
5. You can plot a wire-frame surface of the Maroon Bells (mountains) right over the existing plot. The XSTYLE, YSTYLE, and ZSTYLE keywords are used to select different styles of axis. Here, SURFACE is set to not draw the X, Y, and Z axis because they were already drawn by the SHADE_SURF command.  The /NOERASE keyword allows the SURFACE plot to be drawn over the existing SHADE_SURF plot. Enter the following:
surface,a,xstyle=4,ystyle=4,zstyle=4,/noerase

Displaying a Contour

Another way to view a two-dimensional array is as a contour plot. A simple contour plot of the Data can be created.
1. Set the array size back to its original 350 by 450 size by entering:
a=maroon_bells
2. Plot the contour:
contour,a

That command was very simple, but the resulting plot was not as informative as it could be.

3. Create a customized CONTOUR plot with more elevations and labels by entering:
contour,a,nlevels=8,c_labels=[0,1]

By using the NLEVELS keyword, CONTOUR was told to plot eight equally-spaced elevation levels. The C_LABELS keyword specifies which contour levels should be labeled. By default, every other contour is labeled. C_LABELS allows you to override this default and explicitly specify the levels to label.

4. Similarly, you can create a filled contour plot where each contour level is filled with a different color (or shade of gray) by setting the FILL keyword. To do this, enter:
contour,a,nlevels=8,/fill
5. To outline the resulting contours, make another call to CONTOUR and set the OVERPLOT keyword to keep the previous plot from being erased.  You can add tickmarks that indicate the slope of the contours (the tickmarks point in the downhill direction) by setting the DOWNHILL keyword:
contour,a,nlevels=8,/overplot,/downhill
6. CONTOUR plots can be rendered from a three-dimensional perspective.  First, set up the default 3-D viewing angle by entering:
surfr
7. By using the T3D keyword in the next call to CONTOUR, the contours will be drawn as seen from a 3-D perspective. Enter:
contour,a,nlevels=8,/t3d

Plotting with SHOW3

In addition to IDLs built-in routines, there are many functions and procedures included with IDL that are written in the IDL language and that can be changed, customized, or even rewritten by IDL users.  The SHOW3 procedure is one of these routines.
1. Create a plot that shows a two-dimensional array as an image, wire-frame surface, and contour simultaneously.
show3,a

LIVE_SURFACE

The LIVE_SURFACE procedure allows interactive manipulation using the mouse and keyboard. Usually, LIVE_SURFACE is most suitable for relatively small data sets since the interactive environment requires extra system resources.  After you execute LIVE_SURFACE, you can double-click on a section of the surface to display a properties dialog. The buttons in the upper left of the image window allow you many options (print, undo, redo, copy, line, rectangle, text and so on).
1. Here, to visualize a surface representation, enter the following:
live_surface,a


 
This information is available in alternative formats upon request by individuals with disabilities. Please send email to alt-format@msi.umn.edu or call 612-624-0528.

HOME | QUESTIONS | FEEDBACK
Employment | Events | Links | People | Publications | Support | Welcome
 


URL: http://www.msi.umn.edu/software/fast/tutorial/fast-starting.html
This page last modified on Friday, 03 November, 2000,  09:10:02 CDT  
Please direct questions or problems to help@msi.umn.edu  
Website related questions or problems should be dirrected to webmaster@msi.umn.edu