| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
![]()
To graph selected variables, use the Plot Selector
in the Workspace Browser,
or use the Figure Palette Plot Catalog. Manipulate graphs in plot
edit mode with the Property Editor. For details, see "Plotting
Tools — Interactive Plotting" in the MATLAB Graphics
documentation and "Creating
Graphics from the Workspace Browser" in the MATLAB Desktop
Tools and Development Environment documentation.
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(...)
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). To draw a single contour of level i, use contour(Z,[i i]). Specifying the vector v sets the LevelListMode to manual to allow user control over contour levels. See contourgroup properties for more information.
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 is a matrix, X(1,:) defines the x-axis. If Y is a matrix, Y(:,1) defines the y-axis. When X and Y are matrices, they must be the same size as Z and must be monotonically increasing.
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 x, y coordinates and contour levels for contour lines derived by the low-level contourc function, 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.
If X or Y is irregularly spaced, contour3 calculates contours using a regularly spaced contour grid, and then transforms the data to X or Y.
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.
Plot the three-dimensional contour of a function and superimpose a surface plot to enhance visualization of the function.
[X,Y] = meshgrid([-2:.25:2]); Z = X.*exp(-X.^2-Y.^2); contour3(X,Y,Z,30) surface(X,Y,Z,'EdgeColor',[.8 .8 .8],'FaceColor','none') grid off view(-15,25) colormap cool

For more examples using contour3, see Contour Plots.
contour, contourc, contourf, meshc, meshgrid, surfc
Contour Plots section for more examples
contourgroup properties for related properties
![]() | contour | contourc | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2010- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |