ridgeplot (python)

Aug 2021 by Francisco Juretig

The ridgeplot library allows us to plot estimated densities for multiple distributions in the same plot. The idea is the following: for example, we may have scores for a test for students in 10 schools, and we want to plot the distributions for those 10 schools. Ideally, we would like to see them all together, since it would be much easier to visualize. There are several options for doing this: we can for example use matplotlib, but it requires some extra code. The ridgeplot library makes it incrdibly easy.

Note that here we separated the project into three panels. The top one generates the data and loads some libraries. In this case we will use simulated data: in particular, we will have a list of numpy arrays. Each one will contains 600 gaussian random numbers. The objective will be to pass this list to ridgeplot()

In the two panels below, we are calling ridgeplot() with a different bandwidth. On the right, we use the default one. On the left, we use 4. There is no question the default one works better. We can run this very easily by clicking on >> on the first panel. That runs everything connected to out. We could obviously even try more experiments, with different bandwidths. For this, we just need to add more panels and connect them to the OUT part of the first panel.