我有一个155个数字的数组,范围从0到3.我希望每个数字对应不同的颜色。所以0红色,1蓝色,2绿色和3黄色,然后将数组绘制到颜色条上
origin = 'lower'
#origin = 'upper'
delta = 0.025
x = y = np.arange(-3.0, 3.01, delta)
X, Y = np.meshgrid(x, y)
Z1 = plt.mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = plt.mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = 10 * (Z1 - Z2)
levels = salist ##array of 155
CS3 = plt.contourf(X, Y, Z, levels,
colors = ('r', 'g', 'b','y'),
origin=origin,
extend='both')
plt.colorbar(CS3)