Dear all,

asking question in a good way is art and I am trying to do that :-). I spent whole day trying to put an inset axes within another hosting axes the exact position I want.
and from here  Jae-Joon Lee  gave a good answer using only four lines:

    Bbox = matplotlib.transforms.Bbox.from_bounds(.4, .1, .5, .3)   #numbers in fraction of hosting axes
    trans = ax.transAxes + fig.transFigure.inverted()
    l, b, w, h = matplotlib.transforms.TransformedBbox(Bbox, trans).bounds
    axins = fig.add_axes([l, b, w, h])

It works fine. Now my question is I want inset axes to have 'equal' aspect because I want 1:1 ratio plot. and I found that using axins.set_aspect('equal')
will change the position of the inset axes. Then I tried to adjust the width and height of inset axes with the hosting axes aspect ratio before I draw it so that
I would expect they look already "aspect-equal" before I feed data to it. 

So my first question is,  How can I get the axes aspect ratio, axes.get_aspect() and  axes._aspect both give only 'auto' but not numerical value.
(I assume it's height/width ratio in terms of figure fraction or it's inverse?, I tried this but it doesn't work.)

another side-question, I have a feeling that understanding transform is of great value working with matplotlib. But I don't understand the
four lines above, and I can not find further information either in the matplotlib document or online. Is there any source except having
dig into source code? thanks!!!!!!!!

I make an example script below to show the problem (long but easy). I hope someone could offer some help. :-)

###script showing the problem
#plot two subplot to have ax aspect far from 'equal'
def create_inset_axes(x0,y0,width,height):  #the four numbers are x0,y0,width,height
    Bbox = matplotlib.transforms.Bbox.from_bounds(x0,y0,width,height)
    trans = ax.transAxes + fig.transFigure.inverted()
    l, b, w, h = matplotlib.transforms.TransformedBbox(Bbox, trans).bounds
    return fig.add_axes([l, b, w, h])
def get_axes_aspect_ratio(ax):
    return ratio
ax.text(0.35,0.15,'no any adjustment',transform=ax.transAxes)
axins=create_inset_axes(0.1, 0.3, 0.2, 0.2)
ax.text(0.35,0.4,'explicitly set aspect as equal',transform=ax.transAxes)
axins=create_inset_axes(0.1, 0.55, 0.2, 0.2*ratio) #adjust the height by ax axes width/height ratio
ax.text(0.35,0.7,'adjust with hosting axes width/length ratio',transform=ax.transAxes)


Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax: