logo

... altair.


There are many visualisation libraries in python out there and altair offers some original features. It offers a wide variety of charts, a grammar-like api, loads of interactivity features and the option of exporting directly to the browser.


Notes

To create the final grid chart at the end of the video you need to first create four seperate charts and then operate them together.

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

p1 = (alt.Chart(plot_df)
.mark_line()
.encode(x='date', y='births', color=alt.Color('wday', sort=days))
.properties(width=125, height=125)
.interactive())

p2 = (alt.Chart(plot_df)
  .mark_bar(color='lightblue')
  .encode(x='date:T', y='births:Q', tooltip=['date', 'births'])
  .properties(width=125, height=125))

p3 = (alt.Chart(plot_df)
  .mark_bar(color='lightblue')
  .encode(x='date:T', y='births:Q', tooltip=['date', 'births'])
  .properties(width=125, height=125))

p4 = (alt.Chart(plot_df)
  .mark_bar(color='lightblue')
  .encode(x='date:T', y='births:Q', tooltip=['date', 'births'])
  .properties(width=125, height=125))

(p2 & p1) | (p3 & p4)

Feedback? See an issue? Something unclear? Feel free to mention it here.

If you want to be kept up to date, consider getting the newsletter.