遮盖示例

绘制带有点的线条。

这通常与gappy数据一起使用,以打破数据空白处的界限。

遮盖示例1

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. x = np.arange(0, 2*np.pi, 0.02)
  4. y = np.sin(x)
  5. y1 = np.sin(2*x)
  6. y2 = np.sin(3*x)
  7. ym1 = np.ma.masked_where(y1 > 0.5, y1)
  8. ym2 = np.ma.masked_where(y2 < -0.5, y2)
  9. lines = plt.plot(x, y, x, ym1, x, ym2, 'o')
  10. plt.setp(lines[0], linewidth=4)
  11. plt.setp(lines[1], linewidth=2)
  12. plt.setp(lines[2], markersize=10)
  13. plt.legend(('No mask', 'Masked if > 0.5', 'Masked if < -0.5'),
  14. loc='upper right')
  15. plt.title('Masked line demo')
  16. plt.show()

下载这个示例