Is it possible to apply common axes values to existing figures?
조회 수: 1 (최근 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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!