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!