Which Chart When? A Seaborn Decision Guide With Real Data
Your DataFrame has 6 numeric columns and a stakeholder asks "Show me the distribution, the outliers, and how everything relates โ in one go." You could try 10 different plots at random, or you can follow a decision tree. This article turns the cheatsheet into that tree โ each chart is picked for a specific question, shown on the same mini order dataset so you can compare them side by side.
1. The Data We Will Reuse for Every Chart
10 orders โ same columns as the course, small enough to hold in your head:
| order_id | customer_tier | region | order_amount | discount | items |
|---|---|---|---|---|---|
| 1001 | Gold | North | 420 | 0.05 | 3 |
| 1002 | Silver | South | 85 | 0.20 | 1 |
| 1003 | Gold | North | 890 | 0.02 | 5 |
| 1004 | Bronze | East | 45 | 0.30 | 1 |
| 1005 | Silver | North | 210 | 0.10 | 2 |
Keep this table in mind โ every chart below is just a different lens on the same rows.
2. Decision Tree: Ask One Question, Pick One Chart
| Your Question | Chart | What You See Instantly | One-Liner |
|---|---|---|---|
| "Is order_amount skewed or normal?" | sns.histplot(..., kde=True) | Bars + smooth density curve โ long right tail = skew, two humps = two customer types | sns.histplot(data=df, x='order_amount', kde=True, bins=30, hue='customer_tier') |
| "Are Bronze orders outliers vs Gold?" | sns.boxplot() | Box = Q1โmedianโQ3, whiskers = 1.5รIQR, dots = outliers โ one box per tier | sns.boxplot(data=df, x='customer_tier', y='order_amount', showmeans=True) |
| "Same as boxplot but what's the shape inside?" | sns.violinplot() | Same quartiles as boxplot, but the width = density โ fatter where more orders cluster; split=True compares two groups back-to-back | sns.violinplot(data=df, x='region', y='order_amount', hue='customer_tier', split=True, inner='quartile') |
| "How do all numeric columns relate at once?" | sns.pairplot() | Grid of scatter plots for every pair + histograms on the diagonal โ fastest way to spot "discount goes up when order_amount goes down" | sns.pairplot(df[['order_amount','discount','items']], hue='customer_tier', corner=True, diag_kind='kde') |
3. Reading a Box vs Violin โ Same Data, Two Stories
Take order_amount for Gold vs Bronze from the table above:
- Boxplot collapses each tier to 5 numbers: min whisker, Q1, median, Q3, max whisker. You spot instantly that Bronze median is $45 while Gold median is ~$655 and that order 1003 ($890) is not an outlier for Gold but would be for Bronze.
- Violin shows the same medians/quartiles (
inner='quartile') but the curved width tells you Gold orders are spread wide while Bronze clump narrowly at low amounts โ two very different business shapes that the same median would hide.
Rule of thumb: boxplot for the meeting, violin for the appendix โ same answer, different depth.
4. When One Facet Isn't Enough: Small Multiples With FacetGrid
Sometimes you need the same histogram cut 6 ways (North/Gold, North/Silver, South/Bronze โฆ) without copy-pasting code 6 times. That is FacetGrid โ a grid of identical charts, one per group:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style='ticks')
# One histplot per (region ร tier) cell โ same table, now faceted
g = sns.FacetGrid(df, col='region', row='customer_tier',
margin_titles=True, height=3.5, aspect=1.2)
g.map_dataframe(sns.histplot, x='order_amount', kde=True, color='#0284c7')
g.set_axis_labels('Order Amount ($)', 'Count')
g.set_titles(col_template='Region: {col_name}', row_template='Tier: {row_name}')
plt.tight_layout()
plt.show()
You get 6 histograms in one figure and the stakeholder immediately sees "North Gold has the right tail, East Bronze is flat and low" without you describing it.
Interview cue (Quiz 2 Q10): If asked "violin vs boxplot?" answer: violin = boxplot quartiles + KDE shape โ same data, the width adds density storytelling that a plain box hides.