Matplotlib Contourf在Alpha< 1个 [英] Matplotlib Contourf Plots Unwanted Outlines when Alpha < 1

查看:98
本文介绍了Matplotlib Contourf在Alpha< 1个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Python 2.7中使用matplotlib绘制填充轮廓图.我想将其覆盖在图像上,所以我使用alpha关键字使绘图半透明.当我这样做时,轮廓的主体是正确的透明度,但是轮廓f()在不同级别之间的边界上绘制了不需要的线.我试图用关键字参数linecolor ='none'消除它们,但这没有帮助.

I am using matplotlib in Python 2.7 to plot a filled contour plot. I want to overlay this over an image, so I am using the alpha keyword to make the plot semi-transparent. When I do this, the body of the contours are the correct transparency, but contourf() plots unwanted lines on the boundaries between different levels. I have attempted to eliminate them with the keyword argument linecolor='none', but this has not helped.

代码:

CS = map.contourf(xi,yi,zi,25,alpha = 0.3,linecolor ='none')

CS = map.contourf(xi, yi, zi, 25, alpha=0.3, linecolor='none')

指向问题图像示例的链接;我希望填充的轮廓能够在没有明亮的边界线的情况下相遇:

A link to an image example of the problem; I would like the filled contours to meet without the bright boundary lines:

感谢您对这个问题的任何帮助或见识.

Any help or insight into this problem is appreciated.

推荐答案

尝试打开antialiased=True:

x, y = np.mgrid[-1:1:100j, -1:1:100j]
contourf(x, y, x**2+y**2 + np.random.rand(100, 100)*0.1, 10, alpha=0.3, antialiased=True)

这是我的结果:

这篇关于Matplotlib Contourf在Alpha< 1个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆