色彩映射规范化Symlognorm

演示使用规范以非线性方式将颜色映射映射到数据上。

色彩映射规范化Symlognorm示例

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import matplotlib.colors as colors
  4. """
  5. SymLogNorm: two humps, one negative and one positive, The positive
  6. with 5-times the amplitude. Linearly, you cannot see detail in the
  7. negative hump. Here we logarithmically scale the positive and
  8. negative data separately.
  9. Note that colorbar labels do not come out looking very good.
  10. """
  11. N = 100
  12. X, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)]
  13. Z1 = np.exp(-X**2 - Y**2)
  14. Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
  15. Z = (Z1 - Z2) * 2
  16. fig, ax = plt.subplots(2, 1)
  17. pcm = ax[0].pcolormesh(X, Y, Z,
  18. norm=colors.SymLogNorm(linthresh=0.03, linscale=0.03,
  19. vmin=-1.0, vmax=1.0),
  20. cmap='RdBu_r')
  21. fig.colorbar(pcm, ax=ax[0], extend='both')
  22. pcm = ax[1].pcolormesh(X, Y, Z, cmap='RdBu_r', vmin=-np.max(Z))
  23. fig.colorbar(pcm, ax=ax[1], extend='both')
  24. plt.show()

下载这个示例