当我使用matplotlib countourf
绘制具有蒙版值的数组时,蒙版值显示为白色。我希望它们显得灰色。
我尝试了set_bad
方法,但似乎countourf
无法识别它(尽管它识别set_over
和set_under
方法)。
我可以使用contourf
吗?
或者我是否必须更改我的代码才能使用imshow
,而set_bad
代替countourf
?
答案 0 :(得分:6)
您是否尝试过首先设置背景,例如:
x,y=meshgrid(linspace(0,1),linspace(0,1))
fig=plt.figure()
a=fig.add_subplot(111,axisbg='gray')
z=ma.masked_array(x**2-y**2,mask=y>-x+1)
a.contourf(z)