作者:mobiledu2502891023 | 来源:互联网 | 2023-05-17 06:12
Imtryingtodosomethingasseenontheimageisgivenbelow,我试着做一些如下图所示的事情,Justsettingrever
I'm trying to do something as seen on the image is given below,
或者,您可以屏蔽您的数据,并设置一个屏蔽颜色:
#Create test data:
data = np.random.random_sample((25, 25))
#Create a diagonal mask:
mask = np.diag(np.ones(25))
#Apply mask to data:
masked_data = ma.masked_array(data, mask)
#Set mask color to white:
cm.jet.set_bad(color='white', alpha=None)
#for this to work we use pcolormesh instead of pcolor:
pcolormesh(masked_data, cmap=cm.jet)
colorbar()
show()
This produces essentially the same result, but may suit your needs better as you can set any cell to white, and also the white doesn't show up on the colorbar (see very bottom of above colorbar):
这产生了本质上相同的结果,但可能更适合您的需要,因为您可以将任何单元格设置为白色,而且白色也不会出现在colorbar上(参见上面的colorbar最下面):
![enter image description here](https://www.#.com/go/aHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9rNDlFVy5wbmc=)