Spy 演示

绘制数组的稀疏模式。

  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. fig, axs = plt.subplots(2, 2)
  4. ax1 = axs[0, 0]
  5. ax2 = axs[0, 1]
  6. ax3 = axs[1, 0]
  7. ax4 = axs[1, 1]
  8. x = np.random.randn(20, 20)
  9. x[5, :] = 0.
  10. x[:, 12] = 0.
  11. ax1.spy(x, markersize=5)
  12. ax2.spy(x, precision=0.1, markersize=5)
  13. ax3.spy(x)
  14. ax4.spy(x, precision=0.1)
  15. plt.show()

Spy 演示

参考

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

  1. import matplotlib
  2. matplotlib.axes.Axes.spy
  3. matplotlib.pyplot.spy

下载这个示例