Changing the "save as" filename for Altair chart in google colab

Viewed 41

I'm using altair in google colab and would like to create and download charts with a custom filename instead of 'visualization.svg'. I need to do this for about ~50 charts, I don't mind clicking 'export as SVG' for each, but having to open and check each one and then rename it is going to be quite a pain. I would ideally like to do the following:

for field in fields:
  chart = make_chart(field)
  chart.display(filename=field)
1 Answers

After digging through their code I found the options definition for vega-embed, which is populated from the kwargs in chart.display(..) and the one needed is downloadFileName.

for field in fields:
  chart = make_chart(field)
  chart.display(downloadFileName=field)
Related