RunMat
GitHub

zlabel — Set z-axis labels for 3-D plots, surfaces, and MATLAB zlabel workflows.

zlabel sets or updates the z-axis label for the current axes or an explicit axes handle. In RunMat it returns a text handle, stores the label as subplot-local axes metadata, and supports the same multiline/property workflows as the other shared text builtins used for titles and axis labels.

How zlabel works in RunMat

  • The returned value is a text handle that can be queried and updated through get and set.
  • String scalars, string arrays, and cell arrays can all be used to build multiline z-axis labels in MATLAB-style workflows.
  • Font and text styling properties flow through the shared plotting text-property system, so get and set work on the returned handle.
  • Z-axis labels are subplot-local and stay attached to the axes they were created for.

Examples

Add a z-axis label to a surface plot

[X, Y] = meshgrid(linspace(-3, 3, 50), linspace(-3, 3, 50));
Z = sin(X) .* cos(Y);
surf(X, Y, Z);
zlabel('Height');

Create a multiline z-axis label and style it

[X, Y] = meshgrid(-2:0.2:2, -2:0.2:2);
Z = X .* exp(-X.^2 - Y.^2);
surf(X, Y, Z);
h = zlabel(["Depth", "(km)"]);
set(h, 'FontWeight', 'bold');

Target a specific subplot axes

[X, Y] = meshgrid(linspace(-3, 3, 30), linspace(-3, 3, 30));
Z = sin(X) .* cos(Y);
subplot(1, 2, 1);
surf(X, Y, Z);
ax = subplot(1, 2, 2);
plot3(cos(0:0.1:5), sin(0:0.1:5), 0:0.1:5);
zlabel(ax, 'Trajectory Height');

FAQ

When do I need zlabel vs just xlabel/ylabel?

zlabel only applies to 3-D axes — surf, mesh, plot3, scatter3, etc. For 2-D plots, the z-axis doesn't exist, so zlabel has no effect. If you're plotting in 3-D, always label all three axes so readers can orient themselves.

Can I use LaTeX formatting in zlabel?

You can use LaTeX-style inline math in the label string with standard TeX markup. Subscripts, superscripts, and Greek letters work in label text.

zlabel('Temperature (\circC)');
zlabel('\sigma_{z} (MPa)');

How do I style the z-axis label after creating it?

zlabel returns a text handle that works with get and set. You can change font weight, size, color, and other text properties through that handle.

h = zlabel('Elevation (m)');
set(h, 'FontWeight', 'bold', 'FontSize', 14);

These functions work well alongside zlabel. Each page has runnable examples you can try in the browser.

view, plot3, surf, get, set

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how zlabel 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

Open the sandbox and start running MATLAB code in seconds. No account required.