简体   繁体   中英

How to save figures to pdf as raster images in matplotlib

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?

您可以强制将单个图形元素栅格化,如下所示:

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

我不知道,但是您可以使用“转换”程序(ImageMagick)将jpg转换为pdf:`convert file.jpg file.pdf'。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM