title: How can I make an annotate box anchor to a corner like a legend?
body: <p>I want to use an annotation box, because it allows more on the same ax without any tricks, but how can I anchor it to a corner like a real legend?</p>
  
  <p>Consider</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  x = np.random.normal(0, 1, 100)
  fig, ax = plt.subplots()
  ax.plot(x, alpha=0.6, label="legend")
  ax.annotate(
      s="annotate",
      xy=(0.01, 0.94),
      xycoords="axes fraction",
      bbox=dict(
          boxstyle="round",
          alpha=0.25,
          facecolor = "white",
          edgecolor = "grey"
      ),
  )
  ax.legend(loc="upper right")
  plt.show()
  </code></pre>
  
  <p>It looks fine at first, but breaks when being resized.</p>
  
  <p>This is different than <a href="https://stackoverflow.com/questions/30311809/is-it-possible-to-anchor-a-matplotlib-annotation-to-a-data-coordinate-in-the-x-a">Is it possible to anchor a matplotlib annotation to a data coordinate in the x-axis, but to a relative location in the y-axis?</a> where the aim is to maintain a consistent ratio. Here, I want to maintain an absolute offset from the corner.</p>
  
  <p><a href="https://i.stack.imgur.com/dOf90.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dOf90.png" alt="enter image description here"></a></p>