如何在Matplotlib中将图形另存为pdf作为栅格图像 [英] How to save figures to pdf as raster images in matplotlib

查看:304
本文介绍了如何在Matplotlib中将图形另存为pdf作为栅格图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些使用matplotlib制作的复杂图形.使用savefig命令将其保存为pdf时,使用的是矢量格式,并且pdf需要一段时间才能打开.有什么方法可以将图形另存为pdf作为光栅图像来解决此问题?

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?

推荐答案

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

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

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

这篇关于如何在Matplotlib中将图形另存为pdf作为栅格图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆