matplotlib plt.imshow画图,控制颜色

import matplotlib.pyplot as plt 
import matplotlib as mpl 

colors = ['white', 'blue', 'cyan', 'Lime','yellow'] 

# bounds = [0,1,2,3,4] 
 
cmap = mpl.colors.ListedColormap(colors)
# norm = mpl.colors.BoundaryNorm(bounds, cmap.N)

plt.imshow(a1[num1, :, :], cmap=cmap)  

猜你喜欢

转载自blog.csdn.net/xijuezhu8128/article/details/84745359