Does Streamlit have a default vega-lite specification?

Hi, I am new to using vega-lite for graphing, but I prefer it to matplotlib because the plots look sexier.

First, I have a confusion about the vega-lite specification json. If I don’t specify something like

"mark": {"opacity": 0.3, "type": "area", "color": "#85C5A6"},

For my plot, will it default to something?

Second,if it does not default to something, does Streamlit have some defaults for how it handles coloring line charts?

Gotta say, working with vega lite in streamlit has been the most frustrating part of using streamlit. I feel like the json dict you pass in should be abstracted away.

Right now, there’s line_chart which does everything for you, but has no customization, and vega_lite_chart and altair_chart, which do nothing for you but are fully customizable, and there’s nothing in between. I would expect I could just copy the spec from the line_chart and get the same vega lite chart, but that doesn’t happen, so I’m stuck in purgatory trying to make my vega chart work from scratch.

Alright, I did not realize that altair is actually a python API for vega-lite. My first impression was that altair and vega-lite were related in the way that tensorflow and keras are related: separate packages, one uses the other. Everything I want to do will probably be easier if try using altair, but I’m still interested in a default altair chart tutorial.

Hey @kevinlinxc

You’ll definitely be better using Altair, it mirrors all of the vega-lite spec and gives you autocompletion on the spec :slight_smile:
Streamlit does not interact with your vegalite/altair spec and does not provide a default, it just passes the spec directly to the vegalite parser so, so yeah you have to actually learn the language which takes some time, trial and error :frowning: . I think Streamlit does not provide a default because merging your Altair spec with Streamlit’s default option would mess things up given the sheer number of available options you would have to override.

For me the best way to learn Altair and its spec is to understand each example of the Altair gallery and its vega-lige counterpart, that way you will understand how Altair maps back to vega-lite and slowly be able to express your plot. I did not find a tutorial that can speed you through Altair, this is something you’ll have to dig into :confused: but honestly it’s worth it.

Good luck!
Fanilo

2 Likes