Documentation Center

  • Trial Software
  • Product Updates
我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

contour3

3-D contour plot

Syntax

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

Description

contour3 creates a 3-D contour plot of a surface defined on a rectangular grid.

contour3(Z) draws a contour plot of matrix Z in a 3-D view. 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 levels and the values of contour levels 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).

contour3(Z,n) draws a contour plot of matrix Z with n contour levels in a 3-D view.

contour3(Z,v) draws a contour plot of matrix Z with contour lines at the values specified in 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 contour3(Z,[i i]).

contour3(X,Y,Z), contour3(X,Y,Z,n), and contour3(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 contour3 calculates contours using a regularly spaced contour grid, and then transforms the data to X or Y.

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

contour3(axes_handle,...) plots into the axes with the handle axes_handle instead of into the current axes (gca).

[C,h] = contour3(...) returns a contour matrix, C, that contains the data that defines the contour lines, and a handle, h, to an array of handles to graphics objects. The clabel function uses contour matrix C to label the contour lines. The graphic objects that contour3 creates are patch objects, or if you specify a LineSpec argument, line objects.

Examples

expand all

Create 3-D Contour Plot

Set up matrices X and Y using the meshgrid function. Plot 30 contours of matrix Z.

x = -2:0.25:2;
[X,Y] = meshgrid(x);
Z = X.*exp(-X.^2-Y.^2);
contour3(X,Y,Z,30)

More About

expand all

Tips

If you do not specify LineSpec, the functions colormap and caxis control the color.

Label the contour lines using clabel.

contour3(...) works the same as contour(...) with these exceptions:

  • The contours are drawn at their corresponding Z level.

  • Multiple patch or line objects are created instead of a contourgroup.

  • Calling contour3 with trailing property-value pairs is not allowed.

See Also

| | | | | |

Was this topic helpful?