Is it possible to increase the antialiasing in matplotlib? I can still see some aliasing in my data, I tried several backends and it is still there. The antialiasing flag of the lines is set.
是否有可能增加matplotlib中的抗锯齿效果?我仍然可以在我的数据中看到一些别名,我尝试了几个后端,它仍然存在。线路的抗锯齿标志已设置。
Here you can see what I mean
在这里你可以看到我的意思
It's a sample taken from a Screenshot. It's probably not the best example but I guess one can see the stairs in the line. It was taken with the wxagg backend.
这是一个取自截图的样本。这可能不是最好的例子,但我想可以看到线路上的楼梯。它是用wxagg后端拍摄的。
I'm using matplotlib version 1.01 with Windows 7.
我在Windows 7中使用matplotlib版本1.01。
Update: I don't have the code which produced the previous picture anymore, but I still have the problem. Below is a simple code example which shows the aliasing.
更新:我没有生成上一张图片的代码,但我仍然有问题。下面是一个显示别名的简单代码示例。
import numpy as np
import matplotlib
matplotlib.use('wxAgg')
import matplotlib.pyplot as pl
print 'Backend:', pl.get_backend()
x = np.linspace(0,6,100)
y = np.sin(x)
for a in range(10):
pl.plot( x, a/10.*x, linewidth=1)
pl.show()
It print's Backend: WXAgg
And the resulting plot looks like the following.
它打印的后端:WXAgg结果图如下所示。
Especially the lower red curve shows clear aliasing.
特别是较低的红色曲线显示清晰的混叠。
2 个解决方案
#1
4
The picture you added to your question is already perfectly anti-aliased. It doesn't get any better than this. Have a look at a zoomed version of the image:
您添加到问题中的图片已经完全消除锯齿。它没有比这更好的了。看一下图像的缩放版本:
#2
5
If you save the picture as a .svg file, you will have infinite precision. You can then edit this .svg with something like InkScape, and get how much precision/antialiasing as you like.
如果将图片保存为.svg文件,则将具有无限精度。然后,您可以使用InkScape之类的东西编辑此.svg,并根据需要获得多少精度/抗锯齿。
#1
4
The picture you added to your question is already perfectly anti-aliased. It doesn't get any better than this. Have a look at a zoomed version of the image:
您添加到问题中的图片已经完全消除锯齿。它没有比这更好的了。看一下图像的缩放版本:
#2
5
If you save the picture as a .svg file, you will have infinite precision. You can then edit this .svg with something like InkScape, and get how much precision/antialiasing as you like.
如果将图片保存为.svg文件,则将具有无限精度。然后,您可以使用InkScape之类的东西编辑此.svg,并根据需要获得多少精度/抗锯齿。