SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Yves R. <yve...@ep...> - 2008年09月29日 13:10:52
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.
Thanks in advance.
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 : Yve...@ep...
 SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------
From: Jae-Joon L. <lee...@gm...> - 2008年09月29日 15:02:37
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 <yve...@ep...> 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.
>
>
> Thanks in advance.
>
> 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 : Yve...@ep...
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /