Skip to main content
Albero Academy

Semantic Mappings

How hue, size and style turn columns into visual channels.

Relational Plots8 min

The concept behind hue, size and style is semantic mapping — connecting a data column to a visual property. Understanding how Seaborn handles different data types makes your charts predictable.

Categorical vs numeric hue

Seaborn adapts to the column's type
sns.scatterplot(data=df, x="x", y="y", hue="category") # distinct colours + legend
sns.scatterplot(data=df, x="x", y="y", hue="value") # a continuous colour gradient

A categorical hue gets distinct palette colours and a legend; a numeric one gets a continuous colour gradient and a colorbar. Seaborn detects the type and does the right thing.

Controlling the mapping

order, palette, sizes
sns.scatterplot(data=df, x="x", y="y", hue="tier",
hue_order=["low", "mid", "high"], # legend/colour order
palette="viridis",
sizes=(20, 200)) # size range

Key takeaways

  1. 01Semantic mapping connects a data column to a visual channel (hue/size/style).
  2. 02A categorical hue gives distinct colours + legend; a numeric hue gives a gradient + colorbar.
  3. 03hue_order/size_order control category ordering; palette sets colours.
  4. 04These parameters are consistent across most Seaborn functions.

Finished this chapter?

Mark it complete to track your progress through Seaborn.