Graphics |
Creating Simple Contour Plots
contour
and contour3
display 2- and 3-D contours, respectively. They require only one input argument -- a matrix interpreted as heights with respect to a plane. In this case, the contour functions determine the number of contours to display based on the minimum and maximum data values.
To explicitly set the number of contour levels displayed by the functions, you specify a second optional argument.
Contour Plot of the Peaks Function
display 20 contours of the peaks
function in a 2-D view.
[X,Y,Z] = peaks; contour3(X,Y,Z,20) h = findobj('Type','patch'); set(h,'LineWidth',2) title('Twenty Contours of the peaks Function')
display 20 contours of the peaks
function in a 3-D view and increase the line width to 2 points.
Contour Plots | Labeling Contours |