Other Interactive Plots in altair
Now that we know how to add interactivity to scatter plots, let's learn how to introduce interactivity to two other important visualization types – bar plots and heatmaps. We also encourage you to read the official documentation and look at the official example gallery at https://altair-viz.github.io/gallery/index.html to explore altair so as to be aware of the wide variety of visualization types possible in it.
Exercise 33: Adding a Zoom-In and Zoom-Out Feature and Calculating the Mean on a Static Bar Plot
In this exercise, first, we will generate a simple (static) bar plot and then explore interactivity such as zooming in and out. Then, we'll use the same bar plot and find out the mean of the Happy Planet Index of each region. We'll use the altair library here and the Happy Planet Index dataset:
- Import the
altairmodule asalt:import altair as alt
- Read from the dataset:
hpi_url = "https://raw.githubusercontent...