1
highlightc = np.zeros([N, N])
print highlightc
c = len(highlightc)
colour = [0.21]*c
colour = np.array(colour)
print colour
for x, y in hl:
highlightc[x, y] = 1##set so binary matrix knows where to plot
h=ax.imshow((highlightc*colour), interpolation='nearest',cmap=plt.cm.spectral_r)
fig.canvas.draw()
我創建了一個二元矩陣像這樣,和我想要做的是有情節與零度以下數字的二進制矩陣相乘,取得了一定的色彩。不過,我上面的代碼不會這樣做,並且繪圖仍然是黑色的。我很確定它與我的顏色數組有關,但我不知道如何編輯它,所以這是正確的。 highlightc
是含有[(1,109),(1,102),(67,102),etc]
顏色的二元矩陣matplotlib
您可以使用'h.set_clim([vmin,vmax])''事後調整顏色限制 – tacaswell 2013-04-07 20:02:03