add_axes in inches

Hi,

Is there an easy way to add axes to a figure, but specify the 'rect' in real rather than relative units? For example, something like:

fig.add_axes([0.5,0.5,3.,3.], inches=True)

This would guarantee that for example if I want to increase the canvas size to add more subplots, I don't have to re-adjust all the existing axes. Also, it makes it easier to figure out the aspect ratio of axes, without having to worry about the canvas size. Is there a way to do this already, or is the easiest way to write a wrapper for add_axes that uses the canvas size from fig?

Cheers,

Thomas

unfortunately no. And I'm not sure if matplotlib will ever going to
support it internally.

However, converting axes coordinates given in inches to the normalized
figure coordinates is not that difficult. And this will work as far as
the figure size does not change after the axes position is calculated
in the normalized figure coordinates.

fig = figure(1)

rect_inches = 0.5, 0.5, 3., 3.

from matplotlib.transforms import Bbox, BboxTransformFrom, TransformedBbox
tr = BboxTransformFrom(Bbox.from_bounds(0, 0, *fig.get_size_inches()))
rect = TransformedBbox(Bbox.from_bounds(*rect_inches), tr).bounds

ax = fig.add_axes(rect)

Note that the axes coordinate need to be recalculated whenever the
figure size changes.

While the axes_grid toolkit has some limited support for fixed size
(in inches) axes, I personally never find it useful.

http://matplotlib.sourceforge.net/examples/axes_grid/demo_fixed_size_axes.html

-JJ

ยทยทยท

On Thu, Nov 5, 2009 at 2:31 PM, Thomas Robitaille <thomas.robitaille@...287...> wrote:

Is there an easy way to add axes to a figure, but specify the 'rect'
in real rather than relative units? For example, something like: