title: Convert matplotlib data units to normalized units
body: <p>Does anyone know how to convert matplotlib data units into normalized units? </p>
  
  <p>The reason that I need it is that I need to create a subplot on top of another plot.
  And the default syntax: </p>
  
  <pre><code>plt.axes([0.1,0.1,0.3,0.3])
  </code></pre>
  
  <p>requires normalized coordinates, but I want to use the data coordinates:</p>
  
  <p>For example this code:</p>
  
  <pre><code>  plt.plot([0,2],[2,4]);
    plt.axes([0.3,.3,0.4,.4])
  </code></pre>
  
  <p>produces this:</p>
  
  <p><img src="https://i.stack.imgur.com/nBeb6.png" alt="enter image description here">
  But I'd like to be able to define the location of the subplot using the data coordinates of it
  , something like [0.7,2.5,1.7,3.5].  I've tried to fiddle with axes.transData, axes.get_transform() and the like but didn't succeed to find the right function to do the job</p>