Part IV: seaborn

If matplotlib gives you full control over every pixel, seaborn gives you a faster path to statistical insight. Part IV introduces a library designed from the ground up to make common analytical visualizations easy to produce, statistically rigorous, and visually polished.

seaborn sits on top of matplotlib. Every seaborn plot is a matplotlib Figure and Axes under the hood, which means everything you learned in Part III still applies. What seaborn adds is a declarative, data-oriented interface: instead of manually computing bin edges or positioning bars, you pass a DataFrame and column names, and the library handles the statistical transformations and visual encoding. This is not a shortcut for people who cannot be bothered to learn matplotlib. It is a productivity multiplier for people who already know matplotlib and want to move faster when exploring data.

The four chapters in this part cover seaborn's philosophy and its three major visualization categories:

  • Chapter 16: seaborn Philosophy and the Grammar of Statistical Graphics explains the design decisions behind seaborn's API, including its figure-level versus axes-level distinction, its theme system, and how it integrates with pandas DataFrames.
  • Chapter 17: Distributional Visualization covers the tools for understanding how variables are distributed: histograms, kernel density estimation, rug plots, empirical cumulative distribution functions, violin plots, and ridge plots.
  • Chapter 18: Relational and Categorical Visualization addresses the two most common analytical patterns: showing relationships between continuous variables and comparing values across categorical groups.
  • Chapter 19: Multi-Variable Exploration tackles the challenge of visualizing three, four, or more dimensions simultaneously using pair plots, joint plots, heatmaps, and cluster maps.

A recurring theme in these chapters is the interplay between exploration and communication. seaborn excels at exploratory analysis, the rapid iteration phase where you are asking questions of your data and looking for patterns. But the charts it produces can also be refined, using seaborn's own styling options or by dropping down to the matplotlib layer, into presentation-quality output. Knowing when to stay in seaborn and when to reach for matplotlib is a judgment call that Part IV teaches through practice.

The progressive project continues: the climate dataset that you built as a matplotlib figure in Part III now gets a statistical treatment. You will visualize distributions of annual temperature anomalies, explore relationships between CO2 concentration and temperature change, and use multi-variable techniques to see the full picture at once.

When you finish Part IV, you will have two complementary tools in your kit: matplotlib for total control and seaborn for statistical speed. Part V expands the toolkit further with interactive libraries that let your audience explore the data themselves.

Chapters in This Part