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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
ax | AxesHandle | Yes | — | Axes handle or numeric array of axes handles to link. |
option | StringScalar | Yes | — | Link option: 'x', 'y', 'xy', or 'off'. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:linkaxes:InvalidArgument | Axes handles, option, or argument count is invalid. | linkaxes: invalid argument |
RunMat:linkaxes:Internal | Internal plotting state update fails. | linkaxes: internal operation failed |
How linkaxes works
linkaxes(ax)is equivalent tolinkaxes(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
Link x limits for two subplots
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]Remove a link
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.
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 · cla · clf · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · textscatter · textscatter3 · triplot · waitbar · wordcloud · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zoom
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how linkaxes is executed, line by line, in Rust.
- View the source for linkaxes 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.