Proper display of Altair charts when exporting to PDF
See original GitHub issueI have a Jupyter Notebook which has Altair charts in it for data visualisation. What I would like to do is to export the Notebook together with the charts to PDF using nbconvert
. However, since Altair charts are JavaScript rendered, the exported document displays only alt.Chart(...)
instead. Do you have any suggestions on how to set it up properly without having to export the chart to an image format and pasting it in the notebook?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Saving Altair Charts — Altair 4.2.0 documentation
Altair chart objects have a Chart.save() method which allows charts to be saved in a variety of formats. JSON format . The...
Read more >Altair Monarch 2021 Help File - Exporting Data to PDF Files
With Monarch Classic, you can export extracted report data to a PDF file. If your table has a large number of fields (i.e.,...
Read more >Altair report in HTML but charts only show partially
I send the HTML reports to team members but some of them say they can only see some of the charts displayed.
Read more >Testing Altair-Saver - Nextjournal
Alternatively, you can enable an altair-viewer renderer and display the chart within a notebook as a specific type or set of types. For...
Read more >Post-Pro ocessing - Altair University
to display scaled results (without actually changing the magnitude ... Selection Of Appropriate Type Of Stress: ... button is used to export t....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I found this to be an issue with the way inkscape exports to PDF. A solution would be to overwrite the default inkscape command used by nbconvert to include a
-D
flag which ensures the exported area is the entire drawing:jupyter nbconvert --to pdf --SVG2PDFPreprocessor.command="inkscape {from_filename} --export-pdf=\"{to_filename}\" -D" <your_notebook_name>
Tested with inkscape 0.92.1, the 1.0 version might have different flags.
following these suggestions, I got a version that’s fully working too.
here’s a description of the process from end-to-end if anyone finds this thread too: https://github.com/andyreagan/papermill-altair-pdf