marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.31k stars 155 forks source link

Save altair charts as pdf #1667

Open michaelsch71 opened 1 week ago

michaelsch71 commented 1 week ago

Description

I am hoping to be able to save altair charts as pdf from the burger menu of the displayed chart. Right now "Save as SVG" and "Save as PNG" are already available. Still it would be great to save as pdf also, which is one of the most popular formats to save graphics in a vector format.

Suggested solution

Add a "Save as PDF" version to the burger menu. Altair already has the option to save as pdf internally, by just calling chart.save("filename.pdf"). So I hope this can be used to add the requested feature

Alternative

No response

Additional context

No response

mscolnick commented 1 week ago

@michaelsch71 - we welcome the contribution if you'd like to add support for this.

if you don't want to (that's ok!), you can roll this yourself pretty easily with mo.ui.button and following https://altair-viz.github.io/user_guide/saving_charts.html#png-svg-and-pdf-format

you could even pull this out to its own file and import it into your notebook if you'd like to re-use it across multiple notebooks.