Is it possible to apply common axes values to existing figures?

조회 수: 5 (최근 30일)
Brad
Brad 2017년 1월 26일
편집: John Chilleri 2017년 1월 26일
I'm attempting to open existing figures, and apply a common set of axes to the plots within each figure. But I'm not sure MATLAB will allow for this. I know of the linkaxes function as it applies to subplots. Is there a similar function that can be used for figures?
I'm attempting to do this using the following MATLAB code:
x = linspace(0,2*pi,25);
y = sin(x);
h1 = figure; % 1st figure window
stairs(x,y);
% Save the figure in the current directory
saveas(gcf,'SineWave.fig');
close;
x = linspace(0,3*pi,25);
y = sin(x);
h2 = figure; % 2nd figure window
stairs(x,y);
% Save the figure in the current directory
saveas(gcf,'SineWave2.fig');
close;
pause(1);
openfig('SineWave.fig');
openfig('SineWave2.fig');
This produces 2 figures where the y-axis varies from -1 to 1. The x-axis varies from 0 to 7 from one figure and 0 to 10 for the other.
Is there a way to make the x-axis common (for example, 0 to 12)?
Thank you.

채택된 답변

John Chilleri
John Chilleri 2017년 1월 26일
편집: John Chilleri 2017년 1월 26일
Hello,
You can use:
axis([x1 x2 y1 y2])
where x1 specifies the left side axis limit of the x-axis, x2 the right side axis limit of the x-axis, and similarly y1 is the bottom side axis limit of the y-axis, and y2 is the top side axis limit for the y-axis.
In your case, select your first figure then type:
axis([0 12 -1 1])
then select your second figure and do the same.
Hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by