## Documentation Center |

Contour plot of matrix

`contour(Z)contour(Z,n)contour(Z,v)contour(X,Y,Z)contour(X,Y,Z,n)contour(X,Y,Z,v)contour(...,LineSpec)contour(axes_handle,...)[C,h] = contour(...)`

A contour plot displays isolines of matrix `Z`.
Label the contour lines using `clabel`.

`contour(Z)` draws a contour
plot of matrix `Z`, where `Z` is
interpreted as heights with respect to the *x*-*y* plane. `Z` must
be at least a 2-by-2 matrix that contains at least two different values.
The number of contour lines and the values of the contour lines are
chosen automatically based on the minimum and maximum values of `Z`.
The ranges of the *x*- and *y*-axis
are `[1:n]` and `[1:m]`, where `[m,n]
= size(Z)`.

`contour(Z,n)` draws a contour
plot of matrix `Z` with `n` contour
levels where `n` is a scalar.

`contour(Z,v)` draws a contour
plot of matrix `Z` with contour lines at the data
values specified in the monotonically increasing vector `v`.
The number of contour levels is equal to `length(v)`.
Specifying the vector `v` sets the `LevelListMode` to
manual to allow user control over contour levels. To display a single
contour line at a particular value, define `v` as
a two-element vector with both elements equal to the desired contour
level. For example, to draw a single contour of level `i`,
use `contour(Z,[i i])`.

`contour(X,Y,Z)`, `contour(X,Y,Z,n)`,
and `contour(X,Y,Z,v)` draw contour plots of `Z` using `X` and `Y` to
determine the *x*- and *y*-axis
limits.

If

`X`and`Y`are vectors, then the length of`X`must equal the number of columns in`Z`and the length of`Y`must equal the number of rows in`Z`.If

`X`and`Y`are matrices, then their sizes must equal the size of`Z`.

If `X` or `Y` is
irregularly spaced, then `contour` calculates contours
using a regularly spaced contour grid, and then transforms the data
to `X` or `Y`.

`contour(...,LineSpec)` draws
the contours using the line type and color specified by `LineSpec`. `contour` ignores
marker symbols.

`contour(axes_handle,...)` plots
into axes `axes_handle` instead of `gca`.

`[C,h] = contour(...)` returns
a contour matrix, `C`,
that contains the data that defines the contour lines, and a handle, `h`,
to a contourgroup object. The `clabel` function
uses contour matrix `C` to label the contour lines. `ContourMatrix` is
also a read-only contourgroup property that you can obtain from the
returned handle.

Use contour object properties to control the contour plot appearance.

`clabel` | `contour3` | `contourc` | `contourf` | `contourgroup properties` | `quiver` | `text properties`

Was this topic helpful?