title: Convert from data coordinates to axes coordinates in matplotlib
body: <p>I am trying to convert data points from the data coordinate system to the axes coordinate system in matplotlib.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  
  fig, ax = plt.subplots()
  # this is in data coordinates
  point = (1000, 1000)
  # this takes us from the data coordinates to the display coordinates.
  trans = ax.transData.transform(point)
  print(trans)  # so far so good.
  # this should take us from the display coordinates to the axes coordinates.
  trans = ax.transAxes.inverted().transform(trans)
  # the same but in one line
  # trans = (ax.transData + ax.transAxes.inverted()).transform(point)
  print(trans)  # why did it transform back to the data coordinates? it
  # returns [1000, 1000], while I expected [0.5, 0.5]
  ax.set_xlim(0, 2000)
  ax.set_ylim(0, 2000)
  ax.plot(*trans, 'o', transform=ax.transAxes)
  # ax.plot(*point, 'o')
  fig.show()
  </code></pre>
  
  <p>I read the <a href="https://matplotlib.org/3.2.1/tutorials/advanced/transforms_tutorial.html" rel="nofollow noreferrer">transformation tutorial</a> and tried the solution presented in <a href="https://stackoverflow.com/a/40475221/5472354">this answer</a>, which my code is based on, but it doesn't work. I just can't figure out why, and it's driving me nuts. I'm sure there is an easy solution to it, but I just don't see it.</p>