axis — Query or set axis limits, visibility, and aspect behavior in MATLAB and RunMat plotting.
axis queries or configures limits, visibility, and aspect behavior for the active axes. It supports four-, six-, and eight-element numeric limit vectors, target-handle queries, logical or numeric visibility controls, and command forms such as axis equal, axis image, axis auto, and axis tight.
Syntax
lim = axis()
lim = axis(ax)
axis([xmin xmax ymin ymax | ... cmin cmax])
axis(mode)
axis(visibility)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
ax | NumericScalar | Yes | — | Existing axes handle whose limits are queried. |
limits | NumericArray | Yes | — | Four-, six-, or eight-element x/y, x/y/z, or x/y/z/color limits vector. |
mode | StringScalar | Yes | — | Mode token: 'equal'|'image'|'auto'|'tight'|'manual'|'ij'|'xy'|'on'|'off'. |
visibility | Any | Yes | — | Axes visibility as on/off, logical true/false, or numeric 1/0. |
Returns
| Name | Type | Description |
|---|---|---|
lim | NumericArray | Current x/y limits, with z limits included for a configured 3-D view. |
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
axis()returns the current x and y limits as a four-element double vector, adding z limits for a configured 3-D view.axis(ax)queries the specified axes.- Four-, six-, and eight-element vectors set x/y, x/y/z, or x/y/z/color limits respectively. A
-Inflower endpoint orInfupper endpoint retains the current data-fitted endpoint. - Limit vectors accept all eight integer classes. Authoritative integer storage is validated before one deliberate conversion into host double graphics state, and later limit queries return double.
axis('on'),axis('off'), logical scalars, and numeric zero or one control axes visibility. Numeric visibility accepts all eight integer classes.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.
- GPU-resident limits and visibility controls reject before provider access because
axisis a host graphics-state operation and exposes no interactive GPU-array input surface. - Multiple mode arguments, target-handle setter forms, mode subsets, and complete direction/style mode effects remain general graphics compatibility gaps.
Does RunMat run axis on the GPU?
axis performs no provider dispatch; resident limits and visibility controls reject rather than gathering.
GPU memory and residency
axis returns host-side limit vectors and does not change array GPU residency.
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]); append color limits for the eight-element form. Use -Inf for an automatic lower endpoint or Inf for an automatic upper endpoint. Explicit bounds override auto-fitting until you call axis auto.
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
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 · 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 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.