Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib: how to load and show a PDF image

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).

Thanks in advance!

like image 292
blue2script Avatar asked Mar 30 '14 18:03

blue2script


1 Answers

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

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.

like image 146
rerx Avatar answered Sep 19 '22 20:09

rerx