Hi John, thanks for the reply, but I think your method is not working:
On Wed, Sep 29, 2010 at 15:39, John Hunter <jdh2...@gmail.com> wrote: > On Wed, Sep 29, 2010 at 4:44 AM, Alexander Dietz > <alexanderdie...@googlemail.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 lower > left > > corner is indicated by a red dot - what pixel position does this location > > have? When opening this image in e.g. kview it is easy to find out that > 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 with > > matplotlib? Are there some variables of the axis or the actual plot that > > contain these numbers? > > Take a look at the transformations tutorial. > > http://matplotlib.sourceforge.net/users/transforms_tutorial.html > > To convert from data -> pixel coordinates, use the axes transData > transformation > > In [1]: ax = gca() > > In [2]: ax.transData.transform((0.5, 0.5)) > Out[2]: array([ 333.125, 245. ]) > I have create a different plot (attached) and the point of the upper right corner (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. 432.] Also the lower left points gets wrong coordinates. Maybe I am doing something stupidly wrong here? Thanks Alex > > You can also use mpl events to inspect the coordinates of the point > under the mouse > > > In [3]: fig = gcf() > > In [4]: def on_click(event): > ...: print event.x, event.y > ...: > ...: > > In [5]: cid = fig.canvas.mpl_connect('button_press_event', on_click) > > 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.html for more > info. > > JDH >
<<attachment: mainplotTEST.png>>
------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users