简单Coord03注释示例

简单Coord03注释示例

  1. import matplotlib.pyplot as plt
  2. from matplotlib.text import OffsetFrom
  3. fig, ax = plt.subplots(figsize=(3, 2))
  4. an1 = ax.annotate("Test 1", xy=(0.5, 0.5), xycoords="data",
  5. va="center", ha="center",
  6. bbox=dict(boxstyle="round", fc="w"))
  7. offset_from = OffsetFrom(an1, (0.5, 0))
  8. an2 = ax.annotate("Test 2", xy=(0.1, 0.1), xycoords="data",
  9. xytext=(0, -10), textcoords=offset_from,
  10. # xytext is offset points from "xy=(0.5, 0), xycoords=an1"
  11. va="top", ha="center",
  12. bbox=dict(boxstyle="round", fc="w"),
  13. arrowprops=dict(arrowstyle="->"))
  14. plt.show()

下载这个示例