xlim — Query or set x-axis limits.
xlim([xmin xmax]) sets the x-axis limits, while xlim() returns the current limits as a double vector.
Syntax
limits = xlim()
limits = xlim([xmin xmax])
limits = xlim(mode)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
limits | NumericArray | Yes | — | Two-element numeric vector [xmin xmax]. |
mode | StringScalar | Yes | — | Limit mode string ('auto', 'tight', or 'manual'). |
Returns
| Name | Type | Description |
|---|---|---|
limits | NumericArray | Two-element vector [xmin xmax] or [NaN NaN] when auto. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:xlim:InvalidArgument | Argument count, mode, or limit vector is invalid. | xlim: invalid argument |
RunMat:xlim:Internal | Internal plotting state update fails. | xlim: internal operation failed |
How xlim works
- The two-element limits vector may use single, double, or any native integer class.
- Native integer endpoints are ordered using their exact values before conversion to graphics coordinates.
- Endpoints must be finite, increasing, and remain distinct in the graphics coordinate domain.
- The supported text modes are
'auto','tight', and'manual'.
Examples
Set integer limits
plot(1:10);
xlim(int16([0 12]))Query current limits
limits = xlim()Using xlim with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how xlim changes the result.
Run a small xlim 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 · xlabel · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how xlim is executed, line by line, in Rust.
- View the source for xlim 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.