contour

Contour plots.

contour(Z)
contour(Z,n)
contour(Z,v)
contour(x,y,Z)
contour(x,y,Z,n)
contour(x,y,Z,v)
C = contour(...)

Description

contour(Z) draws a contour plot of matrix Z. The contours are level lines in the units of array Z. The lower-left corner of the plot corresponds to Z(1,1). The number of contour lines and their values are chosen automatically by contour.

contour(Z,n) produces a contour plot of matrix Z with n contour levels.

contour(Z,v) draws a contour plot of Z with contour levels at the values specified in vector v.

contour(x,y,Z), contour(x,y,Z,n), and contour(x,y,Z,v) produce contour plots of Z and use the data in vectors x and y to control the axis scaling on the x- and y-axes. The elements of x and y are equally spaced.

C = contour(...) returns the contour matrix C as described in the function contourc and used by clabel.

To label the levels of a contour plot, see clabel.

Examples

To view a contour plot of the function

over the range -2 <= x <= 2, -2 <= y <= 3, use the statements:

x = -2:.2:2;
y = -2:.2:3;
[X,Y] = meshgrid(x,y);
Z = X.*exp(-X.^2-Y.^2);
contour(x,y,Z)

Diagnostics

If the smallest dimension of Z is less than 2:

Matrix must be 2-by-2 or larger.

Limitations

contour assumes that vectors x and y are monotonically increasing. If x and y are irregularly spaced, the contours are simply stretched apart, which is not the same as contouring the irregularly spaced data.