How to get the position of a plot

Hi guys
I can get the position of the entire figure, or the axes easily, but I am interested in getting the position of the actual plot. That is: the inner rectangle. How do I go about doing that?
Cheers

 Réponse acceptée

Image Analyst
Image Analyst le 27 Nov 2012

0 votes

axesPosition = get(axesHandle, 'Position');
There are a few different flavors of 'Position' - choose the one you want. You can use gca if you want the "current" (last used) axes. If you want the figure instead of the axes on the figure, you can use gcf instead of axesHandle.

4 commentaires

Jakob Sievers
Jakob Sievers le 27 Nov 2012
Modifié(e) : Jakob Sievers le 27 Nov 2012
Using gca gives me the position of the axes (range 0-1) which I understand but am not interested in, and using gcf seems to give me the size of the entire window (range: hundreds). Neither of which are relevant to me however. I need the position of the inner plot.
Image Analyst
Image Analyst le 27 Nov 2012
Position gives you the inner plotting rectangular area. OuterPosition gives you the total outside of the axes which includes labels, tics marks, blank space, etc. I would think that Position should work. See the pictures of what it is in the help for axes properties. How much more "inner" can you get? Can you post a picture of what you need?
Jakob Sievers
Jakob Sievers le 27 Nov 2012
Modifié(e) : Jakob Sievers le 27 Nov 2012
I had a look at it again and it appears that you are absolutely correct. The problem, though, is that I am doing "axis equal", "axis tight" and then the call for position: pos=get(gca,'position'); but it doesnt seem to have been updated to the new axes. How do I get around this?
Jakob Sievers
Jakob Sievers le 27 Nov 2012
Googling around for a solution I stumbled across this handy tool which solves the problem very easily. Thanks again!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by