Dashpoint标签

Dashpoint标签示例

  1. import matplotlib.pyplot as plt
  2. DATA = ((1, 3),
  3. (2, 4),
  4. (3, 1),
  5. (4, 2))
  6. # dash_style =
  7. # direction, length, (text)rotation, dashrotation, push
  8. # (The parameters are varied to show their effects, not for visual appeal).
  9. dash_style = (
  10. (0, 20, -15, 30, 10),
  11. (1, 30, 0, 15, 10),
  12. (0, 40, 15, 15, 10),
  13. (1, 20, 30, 60, 10))
  14. fig, ax = plt.subplots()
  15. (x, y) = zip(*DATA)
  16. ax.plot(x, y, marker='o')
  17. for i in range(len(DATA)):
  18. (x, y) = DATA[i]
  19. (dd, dl, r, dr, dp) = dash_style[i]
  20. t = ax.text(x, y, str((x, y)), withdash=True,
  21. dashdirection=dd,
  22. dashlength=dl,
  23. rotation=r,
  24. dashrotation=dr,
  25. dashpush=dp,
  26. )
  27. ax.set_xlim((0, 5))
  28. ax.set_ylim((0, 5))
  29. plt.show()

下载这个示例