How to resize one axis and keep proportionality?
13 views (last 30 days)
Show older comments
I would like to change my axis' position and size but keep the Y axis proportion with
axis equal
The only way I found to do that was
set(gca,'Units','normalized','Position', [0 0 1 1]);
axis equal
But with this method, the Y-axis is kept to 1 and the X-axis is resized to keep the proportions.
I would like the exact contrary: let the X-axis to 1 and resize the Y-axis with the proportionality.
Any idea to help me?
1 Comment
Gautam Mohan
on 29 Mar 2016
If I am understanding you correctly, you want the Y-axis to be dependent on the X-axis, instead of the other way around.
The simplest way to do this might be to just set the 'YLim' property of the axis. Once you have the XLim and YLim properties, you can do any desired math and reset the values accordingly. For instance, a simple routine to resize the Y-axis to be the same as the X-axis looks like this:
ax = gca; %get the axis
ax.YLim = ax.XLim %set the limits of the Y-axis to be that of the X-axis
Accepted Answer
More Answers (1)
Chad Greene
on 29 Mar 2016
What if you set axis equal before setting axis position? Then you can tinker with xlim however you please.
This is what I'm thinking:
imagesc(peaks)
axis equal
set(gca,'Units','normalized','Position', [0 0 1 1]);
xlim([20 40])
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements 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!