[英]How to save figures to pdf as raster images in matplotlib
I have some complex graphs made using matplotlib. 我有一些使用matplotlib制作的复杂图形。 Saving them to a pdf using the savefig command uses a vector format, and the pdf takes ages to open. 使用savefig命令将它们保存为pdf时,会使用矢量格式,并且pdf需要一段时间才能打开。 Is there any way to save the figure to pdf as a raster image to get around this problem? 有什么方法可以将图形保存为pdf作为光栅图像来解决此问题?
您可以强制将单个图形元素栅格化,如下所示:
text(1,1,'foobar',rasterized=True)
我不知道,但是您可以使用“转换”程序(ImageMagick)将jpg转换为pdf:`convert file.jpg file.pdf'。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.