contour
Draws contour lines, the curves along which a function of two variables is constant.
Category: Graphics > 2-D and 3-D Plots
Syntax
contour(Z)
Contour lines of the matrix Z, using column and row indices as coordinates.
contour(X, Y, Z)
Uses the coordinates X and Y.
contour(___, levels)
A scalar sets the number of levels; a vector sets the levels themselves.
[C, h] = contour(___)
Also returns the contour matrix and the contour object.
Description
A contour map shows a surface from above, like the lines of equal height on a topographic map. Closely spaced lines mean a steep slope. Use contourf to fill the regions between lines and contour3 to lift the lines to their height.
Input arguments
Z- Matrix of values.
X, Y- Coordinates of the grid: matrices the size of
Z, or vectors matching its columns and rows. levels- Number of levels or vector of level values. A vector with one value draws a single line.
Output arguments
C- Contour matrix, see
contourc. h- The
Contourobject; itsLevelListproperty lists the levels drawn.
Example
Levels of a paraboloid
[X, Y] = meshgrid(-2:0.1:2);
Z = X.^2 + Y.^2;
[C, h] = contour(X, Y, Z, [1 2 3]);
disp(h.LevelList)
axis equal
Output
1 2 3