Navigation

Operators and Keywords

Function List:

C++ API

: mesh (x, y, z)
: mesh (z)
: mesh (…, c)
: mesh (…, prop, val, …)
: mesh (hax, …)
: h = mesh (…)

Plot a 3-D wireframe mesh.

The wireframe mesh is plotted using rectangles. The vertices of the rectangles [x, y] are typically the output of meshgrid. over a 2-D rectangular region in the x-y plane. z determines the height above the plane of each vertex. If only a single z matrix is given, then it is plotted over the meshgrid x = 1:columns (z), y = 1:rows (z). Thus, columns of z correspond to different x values and rows of z correspond to different y values.

The color of the mesh is computed by linearly scaling the z values to fit the range of the current colormap. Use caxis and/or change the colormap to control the appearance.

Optionally, the color of the mesh can be specified independently of z by supplying a color matrix, c.

Any property/value pairs are passed directly to the underlying surface object.

If the first argument hax is an axes handle, then plot into this axis, rather than the current axes returned by gca.

The optional return value h is a graphics handle to the created surface object.

See also: ezmesh, meshc, meshz, trimesh, contour, surf, surface, meshgrid, hidden, shading, colormap, caxis.

Demonstration 1

The following code

 clf;
 x = logspace (0,1,11);
 z = x'*x;
 mesh (x, x, z);
 xlabel "X-axis";
 ylabel "Y-axis";
 zlabel "Z-axis";
 title ("mesh() with color proportional to height");

Produces the following figure

Figure 1

Demonstration 2

The following code

 clf;
 x = logspace (0,1,11);
 z = x'*x;
 mesh (x, x, z, z.^2);
 xlabel "X-axis";
 ylabel "Y-axis";
 zlabel "linear scale";
 title ("mesh() with color proportional to Z^2");

Produces the following figure

Figure 1

Demonstration 3

The following code

 clf;
 x = logspace (0,1,11);
 z = x'*x;
 mesh (x, x, z, z.^2);
 set (gca, "zscale", "log");
 xlabel "X-axis";
 ylabel "Y-axis";
 zlabel "log scale";
 title ({"mesh() with color proportional to Z^2", "Z-axis is log scale"});
 try
   if (strcmp (get (gcf, "__graphics_toolkit__"), "gnuplot"))
     title ({"Gnuplot: mesh color is wrong", "This is a Gnuplot bug"});
   endif
 catch
 end_try_catch

Produces the following figure

Figure 1

Demonstration 4

The following code

 clf;
 x = logspace (0,1,11);
 z = x'*x;
 mesh (x, x, z, "facecolor", "none", "edgecolor", "c");
 xlabel "X-axis";
 ylabel "Y-axis";
 zlabel "Z-axis";
 title ({"mesh() default properties overridden", ...
         "transparent mesh with cyan color"});

Produces the following figure

Figure 1

Package: octave