title: convert pixel-coordinates to data-coordinates in matplotlib
body: <p>I am creating a plot with <code>matplotlib.pyplot</code>. 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 <code>ax.transData.inverted().transform(x)</code>, 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 <a href="https://matplotlib.org/tutorials/advanced/transforms_tutorial.html" rel="nofollow noreferrer">this tutorial</a>, but I could not find anything on this problem.</p>
  
  <p>I have also tried <a href="https://stackoverflow.com/a/13662938/3182044">this code</a> 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.</p>
  
  <p>thanks!
  <a href="https://i.stack.imgur.com/I2XQ5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I2XQ5.png" alt="Datapoints from the code example"></a></p>