等高线角遮盖

此示例中显示了以下函数,方法和类的使用:

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. # Data to plot.
  4. x, y = np.meshgrid(np.arange(7), np.arange(10))
  5. z = np.sin(0.5 * x) * np.cos(0.52 * y)
  6. # Mask various z values.
  7. mask = np.zeros_like(z, dtype=bool)
  8. mask[2, 3:5] = True
  9. mask[3:5, 4] = True
  10. mask[7, 2] = True
  11. mask[5, 0] = True
  12. mask[0, 6] = True
  13. z = np.ma.array(z, mask=mask)
  14. corner_masks = [False, True]
  15. fig, axs = plt.subplots(ncols=2)
  16. for ax, corner_mask in zip(axs, corner_masks):
  17. cs = ax.contourf(x, y, z, corner_mask=corner_mask)
  18. ax.contour(cs, colors='k')
  19. ax.set_title('corner_mask = {0}'.format(corner_mask))
  20. # Plot grid.
  21. ax.grid(c='k', ls='-', alpha=0.3)
  22. # Indicate masked points with red circles.
  23. ax.plot(np.ma.array(x, mask=~mask), y, 'ro')
  24. plt.show()

条形码示例

参考

此示例中显示了以下函数和方法的用法:

  1. import matplotlib
  2. matplotlib.axes.Axes.contour
  3. matplotlib.pyplot.contour
  4. matplotlib.axes.Axes.contourf
  5. matplotlib.pyplot.contourf

下载这个示例