How to equalize width & aspect between axes?
조회 수: 9 (최근 30일)
이전 댓글 표시
I have two plots stacked vertically. In one, the x and y data have the same units, so I'm using "axes equal." In the second, x & y do not have the same units, but the x data from both plots are the same. Is there some way to equalize the size and aspect of the x axes across the two plots? I assumed that I could just set the x values in the 'Position' property to be equal, but apparently this is not how "axes equal" functions.
I found that the following procedure seems to work:
~make plot 1~
%Make plot 1
set(gca,'DataAspectRatio',[1 1 1])
ar = get(gca,'PlotBoxAspectRatio')
%Make plot 2
set(gca,'PlotBoxAspectRatio',ar)
Does anyone know a more proper way to do this?
댓글 수: 0
답변 (1개)
Image Analyst
2016년 11월 6일
You can set the size of each axes. You did not do that. Moreover, you didn't even change the current axes between your calls to set() so the two sets's will apply to the same axes. Try this:
handles.axes1.Position = [x1,y1,width1, height1];
handles.axes2.Position = [x2,y2,width2, height2];
You can figure out the 2 parameters based on the 1 parameters if you want. You might also be interested in the "axis equal" and/or "axis square" commands.
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!