# axes and transData

Dear List,

I would like to define a new second plot inside a first plot using the axes command.
But I need the position and size do be defined not by the relative figure coordinates
but by data coordinates.

I have found the following trick :

ax = gca()
f = gcf() x,y = ax.transData.transform([x,y])/f.transFigure.transform([1,1])
a = axes([x,y,dy,dy])

However, if the position is now ok, the size (dx,dy) is still on relative figure coordiate.
Ok, I could think a bit more and find how its possible to transform it, but I would
like to ask the list if there is an easier way to do that.

By the way, why do I have to divide by f.transFigure.transform([1,1]) ?
I expected that ax.transData.transform did return already normalized
values.

yves

···

--
(o o)
--------------------------------------------oOO--(_)--OOo-------
Yves Revaz
Laboratory of Astrophysics EPFL
Observatoire de Sauverny Tel : ++ 41 22 379 24 28
51. Ch. des Maillettes Fax : ++ 41 22 379 22 05
1290 Sauverny e-mail : Yves.Revaz@...2003...
SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------

Hi,

As far as I know, the destination coordinate of trans* is a display
(canvas) coordinate, not the normalized figure coordinate. It has a
dimension of f.get_figwidth()*f.get_dpi(),
f.get_figheight()*f.get_dpi().

For example, transFigure transforms the normalized figure coordinate
to the display coordinate.

See if something like below works for you.

ax = gca()
f = gcf()
x1, y1, x2, y2 = 0.2, 0.3, 0.4, 0.5
trans = ax.transData + f.transFigure.inverted()
ax_x1, ax_y1 = trans.transform_point([x1, y1])
ax_x2, ax_y2 = trans.transform_point([x2, y2])
ax_dx, ax_dy = ax_x2 - ax_x1, ax_y2 - ax_y1
a = axes([ax_x1, ax_y1,ax_dx, ax_dy])

IHTH,

-JJ

···

On Mon, Sep 29, 2008 at 8:10 AM, Yves Revaz <yves.revaz@...2003...> wrote:

Dear List,

I would like to define a new second plot inside a first plot using the
axes command.
But I need the position and size do be defined not by the relative
figure coordinates
but by data coordinates.

I have found the following trick :

ax = gca()
f = gcf()
x,y = ax.transData.transform([x,y])/f.transFigure.transform([1,1])
a = axes([x,y,dy,dy])

However, if the position is now ok, the size (dx,dy) is still on
relative figure coordiate.
Ok, I could think a bit more and find how its possible to transform it,
but I would
like to ask the list if there is an easier way to do that.

By the way, why do I have to divide by f.transFigure.transform([1,1]) ?
I expected that ax.transData.transform did return already normalized
values.

yves

--
(o o)
--------------------------------------------oOO--(_)--OOo-------
Yves Revaz
Laboratory of Astrophysics EPFL
Observatoire de Sauverny Tel : ++ 41 22 379 24 28
51. Ch. des Maillettes Fax : ++ 41 22 379 22 05
1290 Sauverny e-mail : Yves.Revaz@...2003...
SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users