thanks for the reply, but I think your method is not workin= g:

On Wed, Sep 29, 2010 at 15:39, John Hu=
nter <jdh2358@gma=
il.com> wrote:

Take a look at the transformations tutorial.<= div class=3D"h5">On Wed, Sep 29, 2010 at 4:44 AM, Alexander Dietz

<alexanderdietz1@googl= email.com> wrote:

> I would like to know how to find out the extend of the actual image in= a

> plot, in units of pixels.

> As example I have attached a plot which is essentially empty. The lowe= r left

> corner is indicated by a red dot - what pixel position does this locat= ion

> have? When opening this image in e.g. kview it is easy to find out tha= t this

> left corner of the actual plot corresponds to pixel (100,540). And so = the

> upper right corner (the yellow dot) is (720,60).

>

> But how do I find out these coordinates when generating such a plot wi= th

> matplotlib? Are there some variables of the axis or the actual plot th= at

> contain these numbers?

=A0http://matplotlib.sourceforge.net/users/transforms_= tutorial.html

To convert from data -> pixel coordinates, use the axes transData transf= ormation

=A0In [1]: ax =3D gca()

=A0In [2]: ax.transData.transform((0.5, 0.5))

=A0Out[2]: array([ 333.125, =A0245. =A0 ])

I = have create a different plot (attached) and the point of the upper right co= rner (the yellow dot) is still at (720,60) as before. But with transData I = get a completely wrong result:

print ax.transData.transform((10.0, 20.0))

[ 576.=A0 432.]

Al= so the lower left points gets wrong coordinates. Maybe I am doing something= stupidly wrong here?

Thanks

=A0 Alex

=A0

You can also use mpl events to inspect the coordinates of the point

under the mouse

In [3]: fig =3D gcf()

In [4]: def on_click(event):

=A0 ...: =A0 =A0 print event.x, event.y

=A0 ...:

=A0 ...:

In [5]: cid =3D fig.canvas.mpl_connect('button_press_event', on_cli= ck)

In [6]: 188 166.0

300 227.0

384 292.0

In [7]: fig.canvas.mpl_disconnect(cid)

See http://matplotlib.sourceforge.net/users/event_handling.h= tml for more info.

JDH

--001636920b8b4aec0e0491664036--