Y limits affect axis position?

This has been driving me crazy. Generate two axes with the same y positioning, one half the width.
a1=axes;
a2=axes;
a1pos = get(a1,'Position');
set(a2,'Position',[a1pos(1)+a1pos(3)/2,a1pos(2),a1pos(3)/2,a1pos(4)]);
Now change the limits of one of them:
ylim(a1,[2.555 4.0]);
The two axes have the exact same y-positioning, but the plots are slightly offset relative to each other in the y direction! I confirmed that all the position properties are still the same, so what's going on?

回答 (1 件)

Mischa Kim
Mischa Kim 2014 年 3 月 22 日

0 投票

Kurt, this should work:
ylim(a1,[2.555+eps 4.0]);

1 件のコメント

Kurt
Kurt 2014 年 3 月 22 日
編集済み: Kurt 2014 年 3 月 22 日
I figured out that small changes in the limits can change this behavior, but what's actually going on? Why would an infinitesimal change in the limits do this? I don't want to have to keep screwing around with them to fix this in the future.

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2014 年 3 月 22 日

編集済み:

2014 年 3 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by