Code covered by the BSD License  

Highlights from
plotboxpos

4.5

4.5 | 6 ratings Rate this file 8 Downloads (last 30 days) File Size: 1.83 KB File ID: #9615
image thumbnail

plotboxpos

by Kelly Kearney

 

13 Jan 2006 (Updated 19 Oct 2011)

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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
13 Feb 2006 Carlos Moffat

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

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.

28 Jul 2009 Jakob  
08 Feb 2010 Oscar Hartogensis  
20 Apr 2011 dk  
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.

24 Aug 2011 Brian Emery

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

Please login to add a comment or rating.
Updates
14 Feb 2006

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

24 May 2007

Fixed incorrect behavior when aspect ratios set to 'auto', and some bugs regarding plot box aspect ratio.

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.

Tag Activity for this File
Tag Applied By Date/Time
annotation Kelly Kearney 22 Oct 2008 08:12:27
customization Kelly Kearney 22 Oct 2008 08:12:27
plotted Kelly Kearney 22 Oct 2008 08:12:27
area Kelly Kearney 22 Oct 2008 08:12:27
box Kelly Kearney 22 Oct 2008 08:12:27
position Kelly Kearney 22 Oct 2008 08:12:27
plot Kelly Kearney 22 Oct 2008 08:12:27
axis Kelly Kearney 22 Oct 2008 08:12:27
annotation Nabeel Abbood 12 Aug 2009 04:10:39

Contact us at files@mathworks.com