Skip to main content
Albero Academy

Line Plots

Trends over time with automatic aggregation and confidence bands.

Relational Plots9 min

sns.lineplot draws trends — and does something Matplotlib doesn't: when there are multiple y-values per x, it aggregates them (mean by default) and draws a shaded confidence interval automatically.

Automatic aggregation

mean + confidence band
# Many observations per x → Seaborn plots the mean and a 95% CI band
sns.lineplot(data=fmri, x="timepoint", y="signal")
sns.lineplot(data=fmri, x="timepoint", y="signal", hue="region") # a line per group
sns.lineplot(data=df, x="t", y="v", errorbar=None) # turn the band off

When to use it

Key takeaways

  1. 01sns.lineplot draws trends and auto-aggregates multiple y per x (mean) with a CI band.
  2. 02The shaded band shows uncertainty in the mean — great for experimental data.
  3. 03hue draws one line per group with its own band.
  4. 04errorbar controls or removes the interval (None, ("ci",95), ("sd",1)).

Finished this chapter?

Mark it complete to track your progress through Seaborn.