Module 11 Lesson: Statistical and Presentation Visualization with Seaborn
Let us begin
Seaborn builds on Matplotlib and makes many statistical visuals easier.
Use Seaborn when you want to compare distributions, relationships, categories, and segments with less manual chart code.
But remember: a nicer chart is not automatically a stronger analysis.
Long-form data
Seaborn often works best with long-form data.
Long-form data has one observation per row and columns that describe variables.
Example:
| learner_id | week | minutes |
|---|---|---|
| L001 | week_1 | 30 |
| L001 | week_2 | 45 |
This shape makes column mapping clear for x, y, hue, row, or column facets.
Import Seaborn
import seaborn as sns
import matplotlib.pyplot as plt
Seaborn often returns a Matplotlib axes or grid, so Matplotlib knowledge still matters.
Relationship plots
Use relationship plots to inspect how two variables move together.
sns.scatterplot(
data=df,
x="quiz_attempts",
y="practice_minutes",
hue="status"
)
plt.title("Practice Minutes by Quiz Attempts")
Interpretation should be careful:
> The chart suggests a positive relationship in this sample. It does not prove quiz attempts cause more practice.
Distribution plots
Use distribution plots to inspect spread.
sns.histplot(
data=df,
x="practice_minutes",
hue="status",
bins=20,
element="step"
)
plt.title("Practice Minute Distribution by Status")
Distribution charts help show whether averages hide skew or outliers.
Categorical plots
Use categorical plots to compare groups.
sns.boxplot(
data=df,
x="status",
y="practice_minutes"
)
plt.title("Practice Minutes by Status")
Box plots summarize distributions. If the audience may not know box plots, explain them or use a simpler chart.
Facets
Facets create small multiples.
sns.relplot(
data=weekly,
x="week_number",
y="total_minutes",
col="course_level",
kind="line",
marker="o"
)
Facets are useful when one chart would become crowded.
Regression visuals
sns.regplot(
data=df,
x="quiz_attempts",
y="practice_minutes"
)
Regression lines can help inspect a pattern. They are not proof of cause. They are also sensitive to outliers and data quality.
Palettes and style
Use color with purpose.
Good reasons for color:
- show groups;
- highlight one important series;
- separate categories.
Weak reason:
- make the chart look busy.
Keep palettes readable and consistent.
Mini worked example
Question:
> Do completed and paused enrolments show different practice-minute distributions?
Chart:
sns.boxplot(
data=df,
x="status",
y="practice_minutes"
)
plt.title("Practice Minutes by Enrolment Status")
plt.xlabel("Status")
plt.ylabel("Practice minutes")
Careful interpretation:
> Completed enrolments show a higher median in this sample. The chart does not prove completion was caused by practice time because other learner differences are not controlled.
Takeaway
Seaborn helps create statistical visuals quickly, but the analyst is still responsible for chart choice, clean data, and careful interpretation. In the final module, we add Plotly interactivity and build the capstone story.
