Matplotlib & Seaborn
Theme
Palette
Download
Caption (tap to copy)
📖 Deep dive (full written explanation)
This post answers the 'so what' of visualization. It's easy to treat charts as a reporting afterthought — something you make once the analysis is done. The argument here is the opposite: visualization is a core thinking tool, and skipping it means you routinely misunderstand your own data.
The Anscombe hook on the cover is the most famous demonstration of this in all of statistics, which is why it anchors the post.
Summary statistics are compression, and compression is lossy. A mean tells you the center; a standard deviation tells you the spread; neither tells you the shape. Two variables with identical means and variances can be a clean bell curve, a bimodal split, or a skewed tail — and your decisions about each should differ.
The practical danger is overconfidence. A tidy table of stats feels like understanding, but it can quietly hide the very features — multimodality, skew, outliers — that should change your analysis.
Anscombe's quartet, constructed by statistician Francis Anscombe in 1973, is four datasets engineered to share almost identical summary statistics: same means, same variances, same correlation, same fitted regression line. By the numbers, they are indistinguishable.
Plotted, they could not be more different. One is a clean linear relationship. One is a smooth curve that a straight line fits poorly. One is perfectly linear except for a single outlier that drags the whole regression. One is a vertical stripe with one far-off point creating the illusion of correlation. The lesson is blunt: always look at your data.
The compare diagram puts the contradiction in two columns. On the left, the statistics that are essentially identical across all four datasets. On the right, the wildly different shapes those identical numbers conceal. Holding these side by side is what makes the lesson land emotionally, not just intellectually.
The gap between the columns is the entire reason visualization exists as a discipline.
This code slide makes the lesson reproducible in three lines. Seaborn ships the Anscombe dataset built in, and lmplot with col="dataset" draws all four panels in a faceted grid, each with its own fitted line. Running it yourself is more convincing than any description: four panels, four stories, one set of statistics.
The fact that it's this easy to reproduce is itself part of the argument — modern tools make 'just look at it' nearly free.
Charts serve two distinct purposes, and conflating them causes friction. Exploratory plots are for you: fast, rough, disposable, made by the dozen to understand a dataset. Explanatory plots are for an audience: polished, deliberate, built to deliver one clear message convincingly.
The mistake is spending an hour styling an exploratory chart no one else will see, or shipping a rough exploratory chart as if it were a finished explanation. Knowing which mode you're in tells you how much polish is warranted.
The compare diagram contrasts the two modes directly. Exploration is for yourself, fast and disposable, many charts, and this is exactly where Seaborn's good defaults shine because you don't want to think about styling. Explanation is for an audience, polished and final, one message, and that's where Matplotlib's fine control earns its keep.
Mapping each mode to the tool that fits it is a small habit that saves real time.
Good exploration is a numbers game: the more charts you can make cheaply, the more of your data's structure you'll uncover. Seaborn lowers that cost dramatically. A histogram, box plot, pair plot, or heatmap is a single line, so you can survey a dataset from many angles in minutes.
The second-order effect is behavioral. When plotting is cheap, you plot more, and plotting more means you understand more before you commit to a model. Friction is the enemy of exploration.
The pairplot example is the canonical 'survey everything fast' move. One call draws every pairwise scatter of your numeric columns plus each variable's distribution on the diagonal, optionally split by a category via hue. In a single image you can spot correlations, clusters, and separations between groups.
This is the kind of chart you'd never hand-build in Matplotlib during exploration — the cost would be too high — which is precisely why Seaborn changes how much exploring you actually do.
The same power that clarifies can deceive, and the deception is often unintentional. A truncated y-axis exaggerates small differences. A pie chart with many slices destroys any sense of order. A misleading chart doesn't just look unprofessional — it steers real decisions in the wrong direction.
The uncomfortable corollary is that you can fool yourself, not just others. An honestly-intended but poorly-axed chart can convince its own author of a trend that isn't there. Charts are persuasive by nature, so honesty has to be deliberate.
These tips summarize why the effort pays off. Visualization lets you see outliers that averages hide, catch data-quality bugs before they poison a model, communicate a single idea fast, explore before committing, and avoid being fooled by summary statistics.
Each bullet is a concrete payoff, which reframes plotting from a chore into leverage.
This closes the Why post and hands off to the mechanics. Now that you're convinced charts are worth making, the next post opens the engine: the Figure/Axes architecture and the path a plot command takes to become pixels.