0

Is it possible to embed a plotly figure in a LaTeX pdf? Plotly produces very nice interactive figures but when I save them as a png they become less informative. Does anyone know if there is a way to embed from either a saved html file or from an online embed link? The following link shows some example maps like what I would like to embed.

https://plot.ly/python/choropleth-maps/

1

Your wish to use the plotly exports in a Latex generated PDF is likely to be fraught with issues for a number of reasons.

I was able to get several different exports from your link without paying for the premium output of a PDF which I suspect may be static rather than interactive, since there were comments about it possibly being raster!, However if you or someone else have an account you could prove me wrong. I was able from that link able to get a vector.SVG (can't uplode here! ) and interactive.HTML and various hi-res PNG (better than as seen in the html file). here is one PNG but note it does not include the informative right hand scale bar, and for that matter nor did the svg file.enter image description here

I can of course load the png in my pdf viewer and save it as pdf so quality will naturally be the same for both. Neither will be interactive, however that's no problem since my viewer has no support for insecure pdf features such a interactive Actions SWF XFA or other adobe scripting plugins! Thus the Hover for breakdown is meaningless in any viewer other than a browser.

enter image description here

Looking around the web many have requested if adobe pdf supports html javascript but no easy hack seems forthcoming. The best old suggestions were to try converting HTML to SWF and then embed that with acrobat scripts acting as controls.

However I would be more inclined to \usepackage{svg}...\includesvg[]{map} and replace the text with "Click here to view in browser" and simply hyperlink out to the HTML, Keeping It Stupidly Simple for my own usage.

0

PDF is essentialy a static format, like a book. I'm not sure it support interactive content. You should try something like LaTeX −> HTML + js, but with an approach like this you'd better write HTML directly...

  • Hmmmh, how about tex.stackexchange.com/questions/451745/… ? Note that I am not saying that this implies that the plots asked in the question can be embedded, but this shows that there are some interactive plots that can. – user121799 Mar 7 at 23:42
  • pdf support a javascript subset (see [pdfill.com/document_javascript.html], as example). But what the original question ask it's a little bit more than a subset... And get it through LaTeX export sounds like a big mess (for what i know) – Benci Mar 7 at 23:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.