将svg或pdf打印到matplotlib中

将svg或pdf打印到matplotlib中,matplotlib,pdf,svg,plot,imshow,Matplotlib,Pdf,Svg,Plot,Imshow,我将相同的文件保存为.pdf和.svg 我想在常规matplotlib绘图中插入该文件。 我该怎么做 import matplotlib.pyplot as plt pdfFile = open('file.pdf') svgFile = open('file.svg') fig,ax = plt.subplots(1,2) ax[0].imshow(pdfFile) ax[1].imshoe(svgFile) plt.show() 或者,我也试过 from svglib.svglib

我将相同的文件保存为.pdf和.svg 我想在常规matplotlib绘图中插入该文件。 我该怎么做

import matplotlib.pyplot as plt
pdfFile = open('file.pdf') 
svgFile = open('file.svg') 
fig,ax = plt.subplots(1,2)
ax[0].imshow(pdfFile)
ax[1].imshoe(svgFile)
plt.show()
或者,我也试过

from svglib.svglib 
import svg2rlg
from reportlab.graphics import renderPDF, renderPM >>> >>> drawing = svg2rlg("file.svg") >>> renderPDF.drawToFile(drawing, "file.pdf")

Matplotlib无法读取pdf或svg格式。您可以转换为png并作为图像插入。或者,您需要将matplotlib打印文件保存为一个文件,并使用外部方式组合这两个文件。@ImportanceOfBeingErnest:也是eps吗?通常,无法读取矢量形式。是这样吗?@SathishSanjeevi正确。