linkaxes — Link axes limits across multiple axes.

linkaxes(ax) links the x- and y-axis limits for a vector of axes handles. linkaxes(ax, option) links only the requested axis limits or removes existing links.

Syntax

linkaxes(ax)
linkaxes(ax, option)

Inputs

NameTypeRequiredDefaultDescription
axAxesHandleYesAxes handle or numeric array of axes handles to link.
optionStringScalarYesLink option: 'x', 'y', 'xy', or 'off'.

Errors

IdentifierWhenMessage
RunMat:linkaxes:InvalidArgumentAxes handles, option, or argument count is invalid.linkaxes: invalid argument
RunMat:linkaxes:InternalInternal plotting state update fails.linkaxes: internal operation failed

How linkaxes works

  • linkaxes(ax) is equivalent to linkaxes(ax, 'xy').
  • linkaxes(ax, 'x') links X limits while leaving Y limits independent.
  • linkaxes(ax, 'y') links Y limits while leaving X limits independent.
  • linkaxes(ax, 'xy') links both X and Y limits.
  • linkaxes(ax, 'off') removes the supplied axes from any existing linked-axes groups.
  • When a new link is created, linked axes are synchronized to limits that encompass the current limits of every supplied axes handle for the linked axes.
  • Axis-specific links can overlap. For example, one axes can stay linked to another axes on X limits while also being linked to a different axes on Y limits.

Does RunMat run linkaxes on the GPU?

linkaxes performs no provider dispatch and has no GPU kernel implementation.

GPU memory and residency

linkaxes works with host-side graphics handles and does not move arrays between host and GPU memory.

Examples

ax1 = subplot(2,1,1);
ax2 = subplot(2,1,2);
linkaxes([ax1 ax2], 'x');
set(ax1, 'XLim', [0 10]);
get(ax2, 'XLim')

Expected output:

ans = [0 10]
linkaxes([ax1 ax2], 'off');

Using linkaxes with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how linkaxes changes the result.

Run a small linkaxes example, explain the result, then change one input and compare the output.

FAQ

Does linkaxes create axes?

No. It requires existing axes handles such as values returned from subplot, axes, or gca.

Does linking affect future set(ax, 'XLim', ...) calls?

Yes. Linked limits propagate through RunMat's central axes-limit state path, including xlim, ylim, set, and zoom-related limit updates. Unlinked axes continue to use the direct limit-update path.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how linkaxes 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.