Get startedGet started for free

Separating a lot of bands

It is relatively simple to plot a bunch of trend lines on top of each other for rapid and precise comparisons. Unfortunately, if you need to add uncertainty bands around those lines, the plot becomes very difficult to read. Figuring out whether a line corresponds to the top of one class' band or the bottom of another's can be hard due to band overlap. Luckily in Seaborn, it's not difficult to break up the overlapping bands into separate faceted plots.

To see this, explore trends in SO2 levels for a few cities in the eastern half of the US. If you plot the trends and their confidence bands on a single plot - it's a mess. To fix, use Seaborn's FacetGrid() function to spread out the confidence intervals to multiple panes to ease your inspection.

This exercise is part of the course

Improving Your Data Visualizations in Python

View Course

Exercise instructions

  • Set up a facet grid to separate the plots by the city column in eastern_SO2.
  • Send the confidence interval plotting function to map().
  • Color the confidence intervals 'coral'.
  • Help the overlaid mean line drawn with g.map(plt.plot,...) stand out against the confidence bands by coloring it white.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Setup a grid of plots with columns divided by location
g = sns.FacetGrid(eastern_SO2, col = '____', col_wrap = 2)

# Map interval plots to each cities data with corol colored ribbons
g.map(plt.____, 'day', 'lower', 'upper', ____ = 'coral')

# Map overlaid mean plots with white line
g.map(plt.plot, 'day', 'mean', ____ = '____')

plt.show()
Edit and Run Code