CONTOUR Procedure

Draws a contour plot from data stored in a rectangular array.

Usage

    CONTOUR, z[, x, y]

Input Parameters

z—A 2D array containing the values that make up the contour surface.

x—(optional) A vector or 2D array specifying the x-coordinates for the contour surface.

y—(optional) A vector or 2D array specifying the y-coordinates for the contour surface.

Keywords

CONTOUR keywords let you control many aspects of the contour plot’s appearance. These keywords are listed in the following table. For a description, see Graphics and Plotting Keywords.

Background

Data

Path_Filename

[XYZ]Range

Channel

Device

Position

[XYZ]Style

Charsize

Follow

Spline

[XYZ]Thick

Charthick

Font

Subtitle

[XYZ]Tickformat

Clip

Gridstyle

T3d

[XYZ]Ticklen

Color

Levels

Thick

[XYZ]Tickname

C_Annotation

Max_Value

Tickformat

[XYZ]Ticks

C_Charsize

NLevels

Ticklen

[XYZ]Tickv

C_Charthick

Noclip

Title

[XYZ]Title

C_Colors

Nodata

[XYZ]Charsize

[XY]Type

C_Labels

Noerase

[XYZ]Gridstyle

YLabelCenter

C_Linestyle

Normal

[XYZ]Margin

ZAxis

C_Thick

Overplot

[XYZ]Minor

ZValue

Discussion

If the x and y parameters are provided, the contour is plotted as a function of the X,Y locations specified by their contents. Otherwise, the contour is generated as a function of the array index of each element of z.

If x is a vector, each element of x specifies the x-coordinate for a column of z. For example, X(0) specifies the x-coordinate for Z(0, *). If the x parameter is a 2D array, each element of x specifies the x-coordinate of the corresponding point in z (xij specifies the x-coordinate for zij).

If y is a vector, each element of y specifies the y-coordinate for a row of z. If the y parameter is a 2D array, each element of y specifies the y-coordinate of the corresponding point in z (yij specifies the y-coordinate for zij).

CONTOUR draws contours using one of two different methods:

  • The first method, used by default, examines each array cell and draws all contours emanating from that cell before proceeding to the next cell. This method is efficient in terms of computer resources, but does not allow contour labeling.

  • The second method searches for each contour line and then follows the line until it reaches a boundary or closes. This method gives better-looking results with dashed line styles, and allows contour labeling, but requires more computer time. It is used if any of the following keywords is specified:
    C_Annotation, C_Charsize, C_Charthick, C_Labels, Follow, Spline, or Path_Filename.

Although these two methods both draw correct contour maps, differences in their algorithms can cause small differences in the resulting graph.

Example

In this example, a contour plot of random data is plotted as shown in Contour Plot. The random data is generated with the PV‑WAVE IMSL Statistics RANDOMOPT procedure. The Spline keyword causes the contours to be smoothed using cubic splines. The vector assigned to the Levels keyword specifies the levels at which contours are desired. The vector of 1’s assigned to the C_Labels keyword specifies that all contour levels should be labeled. The C_Charsize keyword is used to increase the size of the labels.

; Create a 6-by-6 array of random numbers.
s = 1257
z = RANDOMU(s, 6, 6)
; Create a contour plot from the random data.
CONTOUR, z, /Spline, Levels = [0.2, 0.4, 0.6, 0.8],  $
   C_Labels = [1, 1, 1, 1], C_Charsize = 1.5

Contour Plot

See Also

CONTOUR2,  CONTOURFS, IMAGE_CONT, SHOW3, SURFACE