How to equalize width & aspect between axes?
9 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 6 Nov 2016
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.
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!