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, ...)
xlabel(txt)
xlabel(ax, txt)
xlabel(txt, Name, Value, ...)
xlabel(ax, txt, Name, Value, ...)Inputs
txt- Type
Any- Required
- Yes
- Description
- Label text (string/char/cellstr-like multiline forms).
ax- Type
AxesHandle- Required
- Yes
- Description
- Target axes handle.
props- Type
Any- Required
- Variadic
- Description
- Property/value pairs (Color, FontSize, FontWeight, etc.).
Returns
h- Type
NumericScalar- Description
- Handle to the created/updated xlabel object.
Errors
RunMat:xlabel:InvalidArgument- When
- Axes handle, text payload, or property/value arguments are invalid.
- Message
xlabel: invalid argument
RunMat:xlabel:Internal- When
- Internal plotting state update fails.
- Message
xlabel: internal operation failed
RunMat:xlabel:TooManyOutputs- When
- More than one output is requested.
- Message
xlabel: too many output arguments
Behavior
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 FontSize property 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.
Placement and execution
This command mutates local graphics scene state and may notify the graphics host. Inputs and returned graphics handles are host-owned; worker transfer of numeric handle values does not transfer scene ownership.
Interpreter and compiled routes use the same runtime operation; a browser graphics host or desktop graphics host is required for presentation.
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 · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
More plotting resources
Source you can read
Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.