xlabel — Set the x-axis label for the current or specified axes.
xlabel(txt) sets the x-axis label and returns the label object's graphics handle.
Syntax
h = xlabel(txt)
h = xlabel(ax, txt)
h = xlabel(txt, Name, Value, ...)
h = xlabel(ax, txt, Name, Value, ...)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
txt | Any | Yes | — | Label text (string/char/cellstr-like multiline forms). |
ax | AxesHandle | Yes | — | Target axes handle. |
props | Any | Variadic | — | Property/value pairs (Color, FontSize, FontWeight, etc.). |
Returns
| Name | Type | Description |
|---|---|---|
h | NumericScalar | Handle to the created/updated xlabel object. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:xlabel:InvalidArgument | Axes handle, text payload, or property/value arguments are invalid. | xlabel: invalid argument |
RunMat:xlabel:Internal | Internal plotting state update fails. | xlabel: internal operation failed |
How xlabel works
- Text may be supplied as a string, character vector, string array, or cell array of strings.
- A numeric scalar is converted to label text. Native integer scalars, including one-element integer arrays, use their exact decimal spelling.
- The
FontSizeproperty accepts single, double, and all eight native integer classes. Values must be positive, finite, and within the renderer's supported size range. - An axes handle may be supplied first. RunMat mode additionally accepts a typed-integer alias for an encoded axes handle.
Examples
Label an axis
plot(1:10, rand(1, 10));
xlabel('Time (s)')Use an integer label and font size
xlabel(intmax('uint64'), 'FontSize', uint8(14))Using xlabel with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how xlabel changes the result.
Run a small xlabel example, explain the result, then change one input and compare the output.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · axes · barh · caxis · cla · clf · clim · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · text · textscatter · textscatter3 · triplot · waitbar · wordcloud · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
More plotting resources
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how xlabel is executed, line by line, in Rust.
- View the source for xlabel in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.