我有一些形状(12,1)数组中的标准化直方图数据:>>> hnorm
array([[ 0. ],
[ 0. ],
[ 0.01183432],
[ 0.0295858 ],
[ 0.04142012],
[ 0.04142012],
[ 0.03550296],
[ 0.01775148],
[ 1. ],
[ 0.98816568],
[ 0.56213018],
[ 0. ]])
我想用“热图”的风格来画这个。我是这样做的:
^{pr2}$
这是可行的(轴格式除外)。在
不过,我想定制颜色图,从白色渐变为红色。我尝试过:import matplotlib.colors as col
cdict = {'red': ((0.00, 0.07, 0.14),
(0.21, 0.28, 0.35),
(0.42, 0.49, 0.56),
(0.63, 0.70, 0.77),
(0.84, 0.91, 0.99)),
'green': ((0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0)),
'blue': ((0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0))}
cmap1 = col.LinearSegmentedColormap('my_colormap',cdict,N=256,gamma=0.75)
plt.imshow(hnorm, cmap=cmap1,origin='lower')
这失败了。你知道我做错了什么吗?在