Python Data Visualization, SQL Connectivity & EDA
Back to HIGH-IMPACT VISUAL STORYTELLING: MATPLOTLIB & SEABORN

Advanced Seaborn: The Complete Statistical Charting Cheatsheet

Comprehensive cheatsheet for histplot (with KDE), boxplots, violinplots, pairplots, and FacetGrid matrices.

5 minutesReading
๐ŸŽฏ Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

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_idcustomer_tierregionorder_amountdiscountitems
1001GoldNorth4200.053
1002SilverSouth850.201
1003GoldNorth8900.025
1004BronzeEast450.301
1005SilverNorth2100.102

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 QuestionChartWhat You See InstantlyOne-Liner
"Is order_amount skewed or normal?"sns.histplot(..., kde=True)Bars + smooth density curve โ€” long right tail = skew, two humps = two customer typessns.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 tiersns.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-backsns.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.

Loading progress...