axis — Set axis limits and aspect behavior in MATLAB and RunMat plotting.
axis configures limits and aspect behavior for the active axes. It supports numeric limit vectors and command forms such as axis equal, axis image, axis auto, and axis tight, matching MATLAB and RunMat plotting semantics.
Syntax
ok = axis()
ok = axis([xmin xmax ymin ymax | ... zmin zmax])
ok = axis(mode)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
limits | NumericArray | Yes | — | Axis limits vector [xmin xmax ymin ymax] or [xmin xmax ymin ymax zmin zmax]. |
mode | StringScalar | Yes | — | Mode token: 'equal'|'image'|'auto'|'tight'|'manual'|'ij'|'xy'|'on'|'off'. |
Returns
| Name | Type | Description |
|---|---|---|
ok | LogicalArray | True on success. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:axis:InvalidArgument | Axis argument is unsupported, malformed, non-finite, or has invalid bounds ordering. | axis: invalid argument |
How axis works
- Passing a four-element numeric vector sets
[xmin xmax ymin ymax]directly. axis equalenables equal aspect behavior on the current axes.axis imageenables equal aspect behavior and returns limits to data-fitted bounds, matching MATLAB'saxis equalplusaxis tightbehavior.axis autoclears explicit limits and returns to automatic fitting.axis tightuses data-driven fitting behavior while leaving figure-local plot contents unchanged.- Axis settings are subplot-local because they act on the active axes state.
Examples
Set explicit x and y limits
plot(0:0.1:10, sin(0:0.1:10));
axis([0 10 -1 1]);Force equal axis scaling
t = linspace(0, 2*pi, 200);
plot(cos(t), sin(t));
axis equal;Display image data with square pixels
imagesc([1 2; 3 4]);
axis image;Return to automatic fitting inside a subplot
subplot(1, 2, 1);
plot(1:5, [1 4 2 5 3]);
axis tight;
subplot(1, 2, 2);
plot(1:5, [5 4 3 2 1]);
axis auto;Using axis with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how axis changes the result.
Run a small axis example, explain the result, then change one input and compare the output.
FAQ
How do I get equal aspect ratio so circles look like circles?⌄
Call axis equal after your plot command. This forces one unit on x to equal one unit on y in screen space. Without it, a circle drawn with plot(cos(t), sin(t)) will appear as an ellipse if the figure isn't perfectly square.
t = linspace(0, 2*pi, 200);
plot(cos(t), sin(t));
axis equal;How do I set manual axis limits?⌄
Pass a four-element vector: axis([xmin xmax ymin ymax]). For 3-D plots, use six elements: axis([xmin xmax ymin ymax zmin zmax]). This overrides auto-fitting until you call axis auto to return to data-driven limits.
What does axis tight actually do?⌄
axis tight fits the axes limits snugly around the plotted data with no padding. Compare to axis auto, which may add margin for readability. Use tight when you want the data to fill the entire axes area — useful for image-like plots or when whitespace is wasted space.
What does axis image do?⌄
axis image combines equal aspect behavior with data-fitted limits. It is intended for image displays where pixels should appear square and the axes should fit the image data.
Related Plotting functions
More plotting resources
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how axis is executed, line by line, in Rust.
- View the source for axis 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.