MATLAB: Getting the axis position correctly

axesaxisplotting

I can get the position of the axis easily
figure,plot([0 1], [0 1])
axis equal
AxesHandle=findobj(gcf,'Type','axes');
get(AxesHandle,'Position')
However when I modify the axis limits the axis position does not update.
axis tight
get(AxesHandle,'Position')
still gives me the same answer. How do I get the correct axis position in the second case?

Best Answer

What changes is the tightinset property and plotboxaspectratio.
figure,plot([0 1], [0 1])
axis equal
AxesHandle=findobj(gcf,'Type','axes');
pt1 = get(AxesHandle,{'Position','tightinset','PlotBoxAspectRatio'});
pt1{:}
axis tight
pt2 = get(AxesHandle,{'Position','tightinset','PlotBoxAspectRatio'});
pt2{:}