Livescripts: Usage linkaxes for several figures

1 view (last 30 days)
Within a normal m-file I am able to link axes of different figures with linkaxes. The same command is not working within a livescript. Does anyone know how to do it?

Answers (1)

Cris LaPierre
Cris LaPierre on 14 Mar 2023
The live script uses the same axes for each plot unless you specifically tell it to create a new figure. So likely what is happening is that, rather than 3 separate figures, each plot is replacing the previous plot.
Try adding a figure command before creating each successive plot
% First plot
x1 = linspace(0,6);
y1 = sin(x1);
ax1 = gca;
% Second plot
x2 = linspace(0,10);
y2 = 2*sin(2*x2);
ax2 = gca;
% Third plot
x3 = linspace(0,12,200);
y3 = 4*sin(6*x3);
ax3 = gca;
linkaxes([ax1 ax2 ax3],'xy')
Cris LaPierre
Cris LaPierre on 15 Mar 2023
Ah, got it. I'm definitly not the definitive expert on this, but based on how figures work in a live script, I'm not sure that is currently possible.

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by