本文介绍了当 Alpha <时,Matplotlib Contourf 绘制不需要的轮廓1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Python 2.7 中使用 matplotlib 绘制填充的等高线图.我想将其覆盖在图像上,因此我使用 alpha 关键字使绘图半透明.当我这样做时,轮廓的主体是正确的透明度,但 contourf() 在不同级别之间的边界上绘制不需要的线.我试图用关键字参数 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')

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

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)

这是我的结果:

这篇关于当 Alpha <时,Matplotlib Contourf 绘制不需要的轮廓1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 23:47