pythongoogle-colaboratoryaltairvegavega-embed

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


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)

Solution

  • 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)