Livescripts: Usage linkaxes for several figures

조회 수: 8 (최근 30일)
Georgius
Georgius 2023년 3월 14일
댓글: Cris LaPierre 2023년 3월 15일
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?

답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 3월 14일
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);
plot(x1,y1)
ax1 = gca;
% Second plot
figure
x2 = linspace(0,10);
y2 = 2*sin(2*x2);
plot(x2,y2)
ax2 = gca;
% Third plot
figure
x3 = linspace(0,12,200);
y3 = 4*sin(6*x3);
plot(x3,y3)
ax3 = gca;
linkaxes([ax1 ax2 ax3],'xy')
  댓글 수: 2
Georgius
Georgius 2023년 3월 15일
This links the axis when executing but when afterwards I want to analyze the plot ax1 and zoom in, ax2 and ax3 axis gets not syncronized. This would be beneficial, when e.g. ax1 is the output of a model and ax2+ax3 shows the inputs. With a synchronized behaviour analyzing results would be much easier.
Cris LaPierre
Cris LaPierre 2023년 3월 15일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by