2013-03-13 68 views
1

相反我已創建矩陣陣列繪製的我想要matplotlib

arr_n = np.ones((N,N), dtype = 'bool') 
arr_n[arr_d[:,1], arr_d[:,0]] = 0 
arr_d = np.array(data)  
self.ax.imshow(arr_n, cmap=plt.cm.spectral_r) 

我所選擇spectral_r作爲事後我要添加顏色到的點的矩陣。然而,我遇到了一個問題。而不是繪製我想要的數據(用黑色),而是繪製出我不想要的東西。所以我留下了與我想要的相反的東西。即我想繪製的數據是白色的,而我沒有繪製的部分(黑色)。 data = [(14,64),(23,45),(12,34)]

+1

'spectral'是'spectral_r'的反色配色方案。這有幫助嗎? – Robbert 2013-03-13 09:05:49

+0

謝謝,你的問題很有幫助! – Mattia 2013-12-17 15:39:17

回答

0

您可以使用顏色表的倒數:

self.ax.imshow(arr_n, cmap=plt.cm.spectral) 

或情節的布爾矩陣的逆。

self.ax.imshow(np.invert(arr_n), cmap=plt.cm.spectral)