Calmcode - altair: color

Adding color to a scatter chart Altair.

1 2 3 4 5 6 7 8 9

Adding Color to Altair

We can add other properties to altair as well. Properties like color.

days = ['Mon', 'Tues', 'Wed', 'Thurs', 'Fri', 'Sat', 'Sun']

(alt.Chart(plot_df)
  .mark_point()
  .encode(x='yday', y='births', color=alt.Color('wday', sort=days))
  .properties(width=600, height=250)
  .interactive())

The alt.Color call allows us to be specific in the order that we'd like to create for the legend.