Search code examples
pythonaltairvega-lite

Border around the entire Altair chart


Is it possible to show a border around the entire Altair chart object (so not the stroke param of configure_view)?
I can access the background color which covers the entire chart with .configure(background='beige'), but I can't see how or if I can access the 'stroke' of this background 'panel'.


Solution

  • This is currently not possible in Altair since it is not a feature in Vega Lite. If you open this example in the Vega editor, you can see that the background key only accepts color strings and not dictionaries with "fill" and "stroke".

    Depending on where you are using your charts there might be workaround. For example, you could include the generated HTML in an iframe and set the border of the iframe to mimic a chart outline.