How to save figures to pdf as raster images in matplotlib

我与影子孤独终老i 提交于 2019-11-27 14:50:51

问题


I have some complex graphs made using matplotlib. Saving them to a pdf using the savefig command uses a vector format, and the pdf takes ages to open. Is there any way to save the figure to pdf as a raster image to get around this problem?


回答1:


You can force individual figure elements to be rasterized like this:

text(1,1,'foobar',rasterized=True)



回答2:


Not that I know, but you can use the 'convert' program (ImageMagick') to convert a jpg to a pdf: `convert file.jpg file.pdf'.



来源:https://stackoverflow.com/questions/5609969/how-to-save-figures-to-pdf-as-raster-images-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!