光标

光标示例

  1. from matplotlib.widgets import Cursor
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4. # Fixing random state for reproducibility
  5. np.random.seed(19680801)
  6. fig = plt.figure(figsize=(8, 6))
  7. ax = fig.add_subplot(111, facecolor='#FFFFCC')
  8. x, y = 4*(np.random.rand(2, 100) - .5)
  9. ax.plot(x, y, 'o')
  10. ax.set_xlim(-2, 2)
  11. ax.set_ylim(-2, 2)
  12. # Set useblit=True on most backends for enhanced performance.
  13. cursor = Cursor(ax, useblit=True, color='red', linewidth=2)
  14. plt.show()

下载这个示例