On Thu, Sep 30, 2010 at 3:28 AM, Alexander Dietz <alexanderdietz1@googlemail.com> wrote:

On Wed, Sep 29, 2010 at 16:00, John Hunter <jdh2358@gmail.com> wrote:
On Wed, Sep 29, 2010 at 8:50 AM, Alexander Dietz
<Alexander.Dietz72@googlemail.com> wrote:

> print ax.transData.transform((10.0, 20.0))
> [ 576.  432.]

Why do you say it's wrong?  Note that in mpl, (0,0) is (bottom left),
not (upper,left).  So this is saying that the yellow dot at 10,20
(data coords) is 576 pixels up from the bottom and 432 pixels over
from the left.

This is not correct, either. Since the total width of the image is 800 pixels and the total height is 600 pixels, I get the following coordinates of the yellow dot:

x-coord: = 432
y-coord = 600-576 = 24

but in fact, the position of the yellow dot is still at (720, 60)!. (And even if you swapped x and y coordinates it will never be correct.).

So anyone another idea how to transform a data-point (10,20) to the image coordinates?



I don't think it is technically possible.  Keep in mind that the coordinate system that is used to display figures is merely a convention used by matplotlib and the GUI system.  It is not the same transformation that is used when saving images, and nor should it be because of differences between the resolution of your display and the resolution of your image (typically unknown until save time).

In addition to that issue is the figure window itself.  In particular, the toolbar is also a part of the same display coordinate system.  I would also wonder if there might be some horizontal padding going on that is throwing off the x-coordinates.

Ben Root