Skip to main content
Albero Academy

Customizing with Matplotlib

Fine-tune Seaborn charts using the underlying Axes.

Applied Seaborn8 min

Because Seaborn draws on Matplotlib, you refine its output with everything from the Matplotlib track. The approach differs slightly between axes-level and figure-level functions.

Axes-level: use the returned Axes

customise the Axes
ax = sns.boxplot(data=tips, x="day", y="total_bill")
ax.set_title("Bill by day")
ax.set_ylabel("Total bill ($)")
ax.spines[["top", "right"]].set_visible(False)

Figure-level: use the FacetGrid

customise the grid
g = sns.relplot(data=tips, x="total_bill", y="tip", col="time")
g.set_axis_labels("Bill ($)", "Tip ($)")
g.set_titles("{col_name}")
g.fig.suptitle("Tips by time", y=1.03) # g.fig is the Matplotlib Figure

Key takeaways

  1. 01Seaborn draws on Matplotlib, so all Matplotlib customisation applies.
  2. 02Axes-level functions return the Axes — call ax methods on it.
  3. 03Figure-level functions return a FacetGrid; use g.set_axis_labels/set_titles and g.fig/g.axes.
  4. 04This is how you add the polish (titles, spines, annotations) Seaborn defaults leave off.

Finished this chapter?

Mark it complete to track your progress through Seaborn.