How can I plot the image from a PDF file into a Pyplot figure (e.g. with plt.imshow
, or inside some container I can add with ax.add_artist
)?
Methods that do not work:
import matplotlib.pyplot as plt
im = plt.imread('file.pdf')
(Source: this question, where it works for PNG files.)
from PIL import Image
im = Image.open('file.pdf')
(Source: this doc, but again, it doesn't work for PDF files; the question links a library to read PDFs but the doc shows no obvious way to add them to a Pyplot figure.)
Also, this question exists, but the answers solve the problem without actually loading a PDF file.