好的,以备将来参考。正如@tcaswell建议的那样,我使用了发散地图作为它的一部分。您可以查看以上链接。
import numpy as npfrom matplotlib import pyplot as pltfrom matplotlib.colors import BoundaryNorma=np.random.randn(2500).reshape((50,50))# define the colormapcmap = plt.get_cmap('PuOr')# extract all colors from the .jet mapcmaplist = [cmap(i) for i in range(cmap.N)]# create the new mapcmap = cmap.from_list('Custom cmap', cmaplist, cmap.N)# define the bins and normalize and forcing 0 to be part of the colorbar!bounds = np.arange(np.min(a),np.max(a),.5)idx=np.searchsorted(bounds,0)bounds=np.insert(bounds,idx,0)norm = BoundaryNorm(bounds, cmap.N)plt.imshow(a,interpolation='none',norm=norm,cmap=cmap)plt.colorbar()plt.show()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)