contourfDefine
Zas a function of two variables. In this case, call thepeaksfunction to createZ. Then display a filled contour plot ofZ, letting MATLAB® choose the contour levels.
Z = peaks; contourf(Z) fig2plotly()
Define
Zas a function of two variables,XandY. Then display contours at 10 levels ofZ.
x = linspace(-2*pi,2*pi); y = linspace(0,4*pi); [X,Y] = meshgrid(x,y); Z = sin(X) + cos(Y); contourf(X,Y,Z,10) fig2plotly()
Define
Zas a function ofXandY. In this case, call thepeaksfunction to createX,Y, andZ. Then display contours at levels2and3.The white region corresponds to the heights less than
2. The purple region corresponds to heights between2and3. And the yellow region corresponds to heights that are greater than3.
[X,Y,Z] = peaks(50); contourf(X,Y,Z,[2 3],'ShowText','on') fig2plotly()
Define
Zas a function ofXandY. In this case, call thepeaksfunction to createX,Y, andZ. Then display contours atZ = 2.
[X,Y,Z] = peaks; contourf(X,Y,Z,[2 2]) fig2plotly()
Create a contour plot, and specify the dashed line style.
[X,Y,Z] = peaks; contourf(X,Y,Z,'--') fig2plotly()
Create a filled contour plot. Make the contour lines thicker by setting the
LineWidthproperty to3.
Z = peaks; [M,c] = contourf(Z); c.LineWidth = 3; fig2plotly()
Insert
NaNvalues wherever there are discontinuities on a surface. Thecontourffunction does not draw contour lines in those regions.Define matrix
Zas a sampling of thepeaksfunction. Replace all values in column26withNaNvalues. Then plot the contours of the modifiedZmatrix.
Z = peaks; Z(:,26) = NaN; contourf(Z) fig2plotly()