Aliasing when saving matplotlib filled contour plot to .pdf or .eps

前端 未结 2 2140
Happy的楠姐
Happy的楠姐 2020-12-30 13:00

I\'m generating a filed contour plot with the matplotlib.pyplot.contourf() function. The arguments in the call to the function are:

contourf(xvec,xvec,w,leve         


        
2条回答
  •  情书的邮戳
    2020-12-30 13:40

    After using the useful answer by @pelson for a while, I finally found a proper solution to this long-standing problem (currently in Matplotlib 2.0), which does not require multiple calls to contour or rasterizing the figure.

    I refer to my original answer here for a more extensive explanation and examples.

    In summary, the solution consists of the following lines:

    cnt = plt.contourf(x, y, z)
    
    for c in cnt.collections:
        c.set_edgecolor("face")
    
    plt.savefig('test.pdf')
    

提交回复
热议问题