RunMat
GitHub

mesh — Create wireframe surface plots for grids, height fields, and MATLAB mesh style visualization.

mesh creates wireframe surface plots from vector axes or meshgrid-style coordinates plus a height grid. In RunMat it shares the same surface/object infrastructure as surf, but presents the data as a wireframe-style surface rather than a shaded filled surface, matching MATLAB mesh expectations.

How mesh works

  • mesh(Z) uses implicit axes, while mesh(X, Y, Z) accepts vector axes or meshgrid-style coordinate matrices.
  • The builtin returns a surface handle, so mesh plots can still be inspected through the graphics-object system.
  • mesh is the wireframe-oriented companion to surf; for combined wireframe plus contour overlays, use meshc.
  • RunMat uses the shared surface pipeline for mesh rendering, so view, z-axis labeling, and subplot-local state behave consistently across the surface family.
  • GPU-backed rendering is preferred when the plotting device can consume exported buffers directly.

Examples

Create a wireframe mesh from a height field

[X, Y] = meshgrid(linspace(-2, 2, 60), linspace(-2, 2, 60));
Z = sin(X.^2 + Y.^2);
mesh(X, Y, Z);

Compare wireframe presentation with subplot-local state

subplot(1, 2, 1);
[X, Y] = meshgrid(linspace(-2, 2, 40), linspace(-2, 2, 40));
Z = cos(X) .* sin(Y);
mesh(X, Y, Z);
view(3);
subplot(1, 2, 2);
surf(X, Y, Z);
view(3);

Inspect the returned surface handle from mesh

[X, Y] = meshgrid(1:20, 1:20);
Z = X + Y;
h = mesh(X, Y, Z);
get(h, 'Type')

Expected output:

ans =
    'surface'

Saddle surface showing grid structure

[X, Y] = meshgrid(linspace(-3, 3, 60), linspace(-3, 3, 60));
Z = X.^2 - Y.^2;

mesh(X, Y, Z);
colormap('jet');
colorbar;
title('Hyperbolic Paraboloid');
xlabel('x');
ylabel('y');
zlabel('z = x^2 - y^2');
view(40, 30);
Expected output:
Saddle surface showing grid structure

FAQ

Can I get a filled surface instead of wireframe?

That's what surf is for. mesh draws only the grid lines with transparent faces, while surf fills the faces with colormap-derived colors. If you want the wireframe look but with partial fill, there's no built-in blend — use surf with a low alpha or switch to mesh and accept the wireframe.

How do I combine a mesh with contour lines underneath?

Use meshc instead of mesh. It draws the same wireframe surface but projects contour lines onto the base plane automatically.

[X, Y] = meshgrid(linspace(-2, 2, 50));
Z = sin(X.^2 + Y.^2);
meshc(X, Y, Z);
Can I control transparency on a mesh plot?

Mesh plots don't have filled faces to make transparent — the faces are already open. If you need a semi-transparent surface, use surf and set the FaceAlpha property on the returned handle. The wireframe edges on mesh are always fully opaque.

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contourf · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · clf · figure · fill3 · hold · patch · suptitle · xline · yline

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how mesh works, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Write code or describe what you want to compute. The sandbox is free, no account required.