Get from Ico-github-logo

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

  • plotboxpos(h)
    PLOTBOXPOS Returns the position of the plotted axis region
  • View all files
4.8 | 21 ratings Rate this file 32 Downloads (last 30 days) File Size: 61.5 KB File ID: #9615 Version: 1.4
image thumbnail



Kelly Kearney (view profile)


13 Jan 2006 (Updated )

Returns the position of a plotted axis region

| Watch this File

File Information

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.


This file inspired Label, Antarctic Mapping Tools, and Gramm (Complete Data Visualization Toolbox, Ggplot2/R Like).

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 (25)
15 Nov 2016 Arnaud Laurent

Arnaud Laurent (view profile)

11 Nov 2016 Fritz

Fritz (view profile)

12 Oct 2016 Pierre Morel

Pierre Morel (view profile)

23 Mar 2016 Kelly Kearney

Kelly Kearney (view profile)


As noted in the help, this function is only intended for 2D plots. The math gets much messier for 3D; if someone else wants to figure those calculations out I'd be happy to incorporate them, but I don't really have the motivation to do so myself. I've updated the description on this page to reflect this limitation.

Comment only
23 Mar 2016 Dmitry

Dmitry (view profile)

Nice function, but it does not work for 3d plots with daspect([1 1 1]) !

04 Dec 2015 J.R.

J.R. (view profile)

Please ignore my previous comment. It DOES work with colorbar present.

Comment only
04 Dec 2015 J.R.

J.R. (view profile)

This function does a great job. However, when the colorbar is present in the figure, the function returns the plotted axis region as if a colorbar doesn't exist. I was graphing a pcolor plot with the colorbar on when I discovered this.

Comment only
13 Aug 2015 Christopher Thissen

30 Jun 2015 maf

maf (view profile)

22 Jun 2015 Tianhan

Nice Tool!
Saves me lot of time, thanks!

05 Jan 2015 Eoghan

Eoghan (view profile)

Brilliant little function. Cheers!

20 Aug 2014 Chad Greene

Chad Greene (view profile)

Thank you Kelly for solving a problem I've had for months. This function is well written. You've saved me a world of headaches.

14 Jul 2014 Jeremy Fyke

Works as advertised - thanks.

26 Mar 2014 Ajay

Ajay (view profile)

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;

and your function becomes perfect !
Thanks again.

20 Apr 2011 dk

dk (view profile)

08 Feb 2010 Oscar Hartogensis

28 Jul 2009 Jakob

Jakob (view profile)

14 Feb 2006 Kelly Kearney

Carlos, getInUnits.m is available in the File Exchange: ( Sorry for the confusion; I will update the documentation on this page to clarify this.

Comment only
13 Feb 2006 Carlos Moffat

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

14 Feb 2006

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

26 May 2010 1.1

Small rewrite to remove dependency on external functions

19 Oct 2011 1.2

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

10 Jul 2014 1.3

- verified for R2014b graphics

17 Aug 2015 1.4

Linked to GitHub repository

29 Mar 2016 1.4

Updated description to match the one on GitHub.

Contact us