How to resize one axis and keep proportionality?
古いコメントを表示
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 件のコメント
Gautam Mohan
2016 年 3 月 29 日
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
採用された回答
その他の回答 (1 件)
Chad Greene
2016 年 3 月 29 日
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])
カテゴリ
ヘルプ センター および File Exchange で Argument Definitions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!