Code covered by the BSD License  

Highlights from
plotboxpos

4.72727

4.7 | 11 ratings Rate this file 28 Downloads (last 30 days) File Size: 1.83 KB File ID: #9615
image thumbnail

plotboxpos

by

 

13 Jan 2006 (Updated )

Returns the position of a plotted axis region

| Watch this File

File Information
Description

This function returns the position of the plotted region of an axis, which may differ from the actual axis position, depending on the axis limits, data aspect ratio, and plot box aspect ratio. The position is returned in the same units as the those used to define the axis itself. This function can only be used for a 2D plot.

Example:

f1 = figure('Position', [50 50 300 300]);
a1 = axes('Position', [.25 .25 .5 .5], ...
         'DataAspectRatio', [10 1 1], ...
         'XLim', [0 100], ...
         'YLim', [0 20]);
pos = plotboxpos(gca);
f2 = figure('Position', [50 50 300 300]);
a2 = axes('Position', pos);

MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (12)
26 Mar 2014 Ajay  
16 Jan 2014 Marcelo Soto Thompson  
24 Apr 2013 Claudia

Thanks so much. That's awesome!

14 Apr 2013 Chethan Pandarinath

This is fantastic. Thanks.

11 Jan 2013 Mathieu  
24 Aug 2011 Brian Emery

Finds the position of the axes after modifying the DataAspectRatio and PlotBoxAspectRatio. This is exactly what I need, thanks!

09 Aug 2011 Fran├žois Beauducel

Very useful function, thanks.
It's missing only a little test like:

if nargin < 1
h = gca;
end

and your function becomes perfect !
Thanks again.

20 Apr 2011 dk  
08 Feb 2010 Oscar Hartogensis  
28 Jul 2009 Jakob  
14 Feb 2006 Kelly Kearney

Carlos, getInUnits.m is available in the File Exchange: (http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8898&objectType=file). Sorry for the confusion; I will update the documentation on this page to clarify this.

13 Feb 2006 Carlos Moffat

Kelly, getInUnits does not exist, as far as I can tall, as a MATLAB function.

Updates
14 Feb 2006

Clarified use of another File Exchange function (getInUnits.m).

26 May 2010

Small rewrite to remove dependency on external functions

19 Oct 2011

Now defaults to current axis if no input provided. Also updated example image to a simpler one.

Contact us