Matplotlib Plots Lose Transparency When Saving as .ps/.eps

前端 未结 7 1271
南旧
南旧 2020-12-01 05:01

I\'m having an issue with attempting to save some plots with transparent ellipsoids on them if I attempt to save them with .ps/.eps extensions.

Here\'s the plot sav

7条回答
  •  长情又很酷
    2020-12-01 05:42

    As mentioned above, the best and easiest choice (if you do not want to loose resolution) is to rasterized the figure

    f = plt.figure()
    f.set_rasterized(True)
    
    ax = f.add_subplot(111)
    
    ax.set_rasterized(True)
    f.savefig('figure_name.eps',rasterized=True,dpi=300)
    

    This way, you can manage the size by dpi option as well. In fact, you can also play with the zorder below you want to apply the rasterization:

    ax.set_rasterization_zorder(0)
    

    Note: It is important to keep f.set_rasterized(True) when you use plt.subplot and plt.subplot2grid functions. Otherwise, label and tick area will not appear in the .eps file

提交回复
热议问题