Skip to content Skip to sidebar Skip to footer

Get Coordinates Of Matplotlib Plot Figure Python With Mouse Click

I have been trying to get the mouse x,y coordinates to variables according to matplotlib plot scale not pixels but it only returns me the integer components like 0.0 or 1.0 I want

Solution 1:

You are getting accurate results, ix and iy are floats with the accuracy you want. The problem is the formatting in

print 'x = %d, y = %d' % (ix, iy)

%d means that the number should be displayed as an integer, and exactly that is happening here. If you try out %f for float representation:

print 'x = %f, y = %f' % (ix, iy)

you'll see that you're getting accurate results.


Post a Comment for "Get Coordinates Of Matplotlib Plot Figure Python With Mouse Click"