White lines in matplotlib's pcolor

前端 未结 3 2155
梦毁少年i
梦毁少年i 2020-12-01 14:22

In some pdf viewers such as Preview on OSX, plots made with matplotlib\'s pcolor have white lines (see image below). How can I get rid of them?

The sour

3条回答
  •  醉酒成梦
    2020-12-01 14:59

    The accepted answer didn't work very well for me. I seemed to have gotten closer by using antialiased=True, in addition to linewidth=0. This was with matplotlib version 3.0.2. Note the middle plot corresponds to the best version.

    fig, axes = plt.subplots(1,3, figsize=(15,5))
    axes[0].pcolormesh(XX, YY, ZZ_r, zorder=-1, norm=norm, cmap='magma', alpha=0.5, antialiased=True)
    axes[1].pcolormesh(XX, YY, ZZ_r, zorder=-1, norm=norm, cmap='magma', alpha=0.5, antialiased=True, linewidth=0.0)
    axes[2].pcolormesh(XX, YY, ZZ_r, zorder=-1, norm=norm, cmap='magma', alpha=0.5, antialiased=False, linewidth=0.0)
    

提交回复
热议问题