1
你好,我不知道什麼是不對的this.I有這個mgrib結合z值Matplotlib imshow()出錯
pp=array(Arrays) #This is my Array that extract a Grid
y,x=np.mgrid[slice(0,25, 1),slice(0,42, 1)]
z=pp[y,x,1] #Extract Z with x,y position in the Array of pp
當執行:
cmap = plt.get_cmap('Azul-Rojo-Alpha')
norm = matplotlib.colors.Normalize(vmax=pp[:,:,1].max(), vmin=pp[:,:,1].min())
plt.imshow(z, cmap=cmap, norm=norm, interpolation='nearest')
給我這個錯誤:
ValueError: data mapping points must start with x=0. and end with x=1
如果檢查並且錯誤在這裏:
cdict1 = {
'red': ((0.0, 0.0, (7.0/255.0)),
(1.0, 1.0, 1.0)),
'green': ((0.0, 0.0, (183.0/255.0)),
(0.0, (44.0/255.0), 1)),
'blue': ((0.0, 0.0,1.0),
(1.0, 0.0, 1.0))
}
cdict1['alpha'] = ((0.0, 1.0, 1.0),
(0.5, 0.0, 0.0),
(1.0, 1.0, 1.0))
TEMPE = LinearSegmentedColormap('Azul-Rojo-Alpha', cdict1)
plt.register_cmap(cmap=TEMPE)
但我不知道爲什麼。
對不起我的英語
好像你的正常化,不是出於某種原因正常工作..但我不能說更多。 – cgeroux
對不起,我收錄了更多信息 – virtualsets