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

3 ビュー (過去 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 Center および File ExchangeAnnotations についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by