各位 用科罗拉马普计算出来的彩色添加:
import matplotlib.colorbar as cbar
import pylab as pl
import numpy as np
N = 50
xs = np.random.randint(0, 100, N)
ys = np.random.randint(0, 100, N)
ws = np.random.randint(10, 20, N)
hs = np.random.randint(10, 20, N)
vs = np.random.randn(N)
normal = pl.Normalize(vs.min(), vs.max())
colors = pl.cm.jet(normal(vs))
ax = pl.subplot(111)
for x,y,w,h,c in zip(xs,ys,ws,hs,colors):
rect = pl.Rectangle((x,y),w,h,color=c)
ax.add_patch(rect)
cax, _ = cbar.make_axes(ax)
cb2 = cbar.ColorbarBase(cax, cmap=pl.cm.jet,norm=normal)
ax.set_xlim(0,120)
ax.set_ylim(0,120)
pl.show()