Plot level curves (contour lines) of the matrix z, using the contour matrix c computed by
contourc
from the same arguments; see the latter for their interpretation. The set of contour levels, c, is only returned if requested. For example:x = 0:2; y = x; z = x' * y; contour (x, y, z, 2:3)The style to use for the plot can be defined with a line style style in a similar manner to the line styles used with the
plot
command. Any markers defined by style are ignored.The optional input and output argument h allows an axis handle to be passed to
contour
and the handles to the contour objects to be returned.
The following code
[x, y, z] = peaks (); contour (x, y, z);
Produces the following figure
![]() |
The following code
[theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64)); [X, Y] = pol2cart (theta, r); Z = sin(2*theta).*(1-r); contour(X, Y, abs(Z), 10)
Produces the following figure
![]() |