RunMat
GitHub

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

NameTypeRequiredDefaultDescription
limitsNumericArrayYesAxis limits vector [xmin xmax ymin ymax] or [xmin xmax ymin ymax zmin zmax].
modeStringScalarYesMode token: 'equal'|'image'|'auto'|'tight'|'manual'|'ij'|'xy'|'on'|'off'.

Returns

NameTypeDescription
okLogicalArrayTrue on success.

Errors

IdentifierWhenMessage
RunMat:axis:InvalidArgumentAxis 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 equal enables equal aspect behavior on the current axes.
  • axis image enables equal aspect behavior and returns limits to data-fitted bounds, matching MATLAB's axis equal plus axis tight behavior.
  • axis auto clears explicit limits and returns to automatic fitting.
  • axis tight uses 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.

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · clf · figure · fill3 · hold · patch · polarplot · print · suptitle · xline · yline

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.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.