Matplotlib:如何加载和显示PDF图像 [英] Matplotlib: how to load and show a PDF image

查看:71
本文介绍了Matplotlib:如何加载和显示PDF图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单:我有一个 PDF 图,我想与一些数据分析的结果一起显示.然而,即使是广泛的Google搜索也无法提供一种在图中加载和显示PDF的方法(我只找到了JPG或PNG等光栅图像的标准结果).

My problem is simple: I have a PDF figure I would like to show alongside the results of some data analysis. Yet even an extensive Google search did not bring up a way to load and show a PDF in a figure (I only found the standard results for raster images like JPG or PNG).

提前谢谢!

推荐答案

到目前为止,我不认为Matplotlib自己支持绘制导入的矢量图形.

I don't think Matplotlib supports plotting imported vector graphics on its own as of today.

最简单的方法可能是将您在 Matplotlib 中生成的图形保存到 SVG,将您的 PDF 转换为 svg (pdf2svg 在大多数情况下运行良好)并在第二步中组合两个 SVG,例如使用 svg_utils.请注意,您可以在一个脚本中完成所有这些操作.

The easiest approach would probably be to save your figure generated in Matplotlib to SVG, convert your PDF to svg (pdf2svg works well most of the time) and the combine the two SVGs in a second step, for instance using svg_utils. Note that you can do all this in a single script.

这篇关于Matplotlib:如何加载和显示PDF图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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