[英]Set color to be used for an array masked values plotted with matplotlib contourf
When I plot an array with masked values, using matplotlib countourf
, the masked values appear white. 当我使用matplotlib countourf
绘制具有蒙版值的数组时,蒙版值显示为白色。 I want them to appear grey. 我希望它们显得灰色。
I tried the set_bad
method, but it seems countourf
doesn't recognize it (although it recognizes the set_over
and set_under
methods). 我试过set_bad
方法,但似乎countourf
不承认它(尽管它承认set_over
和set_under
方法)。
Is there any other method I can use with contourf
? 有没有其他方法我可以使用contourf
?
Or will I have to change my code to use imshow
, which understands set_bad
, instead of countourf
? 或将我不得不改变我的代码使用imshow
,这理解set_bad
代替, countourf
?
Have you tried setting first the background, like: 您是否尝试过首先设置背景,例如:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.