MATLAB meshz in MATLAB®
Learn how to make 3 meshz charts in MATLAB, then publish them to the Web with Plotly.
Display Curtain Around Mesh Plot
Create three matrices of the same size. Then plot them as a mesh plot with a curtain. The mesh plot uses Z
for both height and color.
[X,Y] = meshgrid(-3:.125:3); Z = peaks(X,Y); meshz(X,Y,Z) fig2plotly()
Specify Colormap Colors for Mesh Plot With Curtain
Specify the colors for a mesh plot and surrounding curtain by including a fourth matrix input, C
. The mesh plot uses Z
for height and C
for color. Specify the colors using a colormap, which uses single numbers to stand for colors on a spectrum. When you use a colormap, C
is the same size as Z
. Add a color bar to the graph to show how the data values in C
correspond to the colors in the colormap.
[X,Y] = meshgrid(-3:.125:3); Z = peaks(X,Y); C = gradient(Z); meshz(X,Y,Z,C) colorbar fig2plotly()
Modify Appearance of Mesh Plot With Curtain
Create a mesh plot with a curtain around it. To allow further modifications, assign the surface object to the variable s
.
[X,Y] = meshgrid(-5:.5:5); Z = Y.sin(X) - X.cos(Y); s = meshz(X,Y,Z)
s = Surface (meshz) with properties: EdgeColor: 'flat' LineStyle: '-' FaceColor: [1 1 1] FaceLighting: 'none' FaceAlpha: 1 XData: [25x25 double] YData: [25x25 double] ZData: [25x25 double] CData: [25x25 double] Show all properties
s.EdgeColor = 'b';
fig2plotly()