I am creating a plot with matplotlib.pyplot
. For this image I need a function that maps pixel-coordinates to the coordinates of the data (for interaction with the user in another GUI-system outside of python). I have tried the function ax.transData.inverted().transform(x)
, since it maps display-coordinates to data-coordinates. But the numbers that I get have an offset of roughly 23 pixels in x-direction. I went through this tutorial, but I could not find anything on this problem.
I have also tried this code from stackoverflow, where the printed x-coordinates have an offset of 25 pixels. I could see that Maybe the area left to the y-axis is not included there? I definitely need it to be included. In the attached picture I am comparing what the code from stackoverflow yields vs what MS paint tells me about the x-coordinate of the red dot. They are not the same.