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

3 次查看(过去 30 天)
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