[IPython-User] Automatically embedding PDF version of figures

Jon Wilson jsw@fnal....
Tue Jan 22 20:00:42 CST 2013


Hi all,
In my field, it is customary to provide a web page documenting an 
analysis (we invented the web, after all ;).  The principal aim is to 
distribute the figures produced by the analysis.  Because PDF / EPS play 
nicely with TeX, those are provided for the purpose of writing papers 
and proceedings.  However, they don't display nicely in web browsers, so 
raster versions are also provided.  Typically, the webpage will display 
the raster graphic, and make the image a link to the vector graphic.

I have recently gotten into the habit of a) working in the IPython 
notebook and b) communicating results to my colleagues using static HTML 
views of the notebook produced by nbconvert (what a wonderful pair of 
tools, by the way, thank you for them!).  I am, for the first time since 
starting to use the notebook and nbconvert, in the process of making an 
analysis public, and so I need a webpage of the type described above.

The nbconvert static HTML files very nicely embed PNG images of my 
figures using Data URIs, all without me needing to do anything to make 
that happen (which is nice when there are dozens of figures). Is there a 
reasonably straightforward way to also produce PDF copies of my figures, 
and have the PNG images link to those?  I can produce PDF figures using 
savefig, but this requires substantial bookkeeping on my part: I have to 
manually insert a call to savefig for every figure, and then edit the 
static HTML to link to those files.

Could we generate the data for PDF figures and store it in an object tag 
or something?  I'm very new to the whole concept of Data URIs, and so I 
don't know what is possible (or reasonable) with them. What changes to 
IPython and/or nbconvert would be necessary, assuming that Data URIs are 
a reasonable way to go with this?
Best regards,
Jon


More information about the IPython-User mailing list