Displaying Contours with Direct Graphics
Working with images using Direct graphics is not as convenient as using the iImage tool, but may be desirable if you are incorporating images into a larger widget-based application, or if you need to programatically create a large number of processed images.
In this example, we will display a two-dimensional array as a contour plot using IDL Direct graphics. Enter the following commands at the IDL command line:
- If you have not already done so, restore the
marbells.datSAVE file. - Since we are using Direct graphics, tell IDL to use a maximum of 256 colors and load a simple grayscale color map.
- Plot the contour.
- Create a customized CONTOUR plot with more contour lines.

- Similarly, you can create a filled contour plot where each contour level is filled with a different color (or shade of gray) by using the FILL keyword.

- To outline the resulting contours, make another call to CONTOUR and use the OVERPLOT keyword to overlay the previous plot.
- CONTOUR can plot surface data in a three-dimensional perspective.
- By using the T3D keyword, the contours are drawn in a three-dimensional perspective.

RESTORE, FILEPATH('marbells.dat', $
SUBDIRECTORY=['examples', 'data'])
DEVICE, RETAIN=2, DECOMPOSED=0
LOADCT, 0
CONTOUR, elev, NLEVELS=8, $
C_LABELS=[0,1]
The NLEVELS keyword directs CONTOUR to plot eight equally-spaced contours. The C_LABELS keyword specifies which contour levels should be labeled (by default, every other contour is labeled).
CONTOUR, elev, NLEVELS=8, /FILL
You can add tickmarks that indicate the slope of the contours (the tickmarks point downhill) by using the DOWNHILL keyword.

CONTOUR, elev, NLEVELS=8, $
/OVERPLOT, /DOWNHILL
First, set a three-dimensional viewing angle.
