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
sns.scatterplot(data=df, x="x", y="y", hue="category") # distinct colours + legendsns.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
sns.scatterplot(data=df, x="x", y="y", hue="tier",hue_order=["low", "mid", "high"], # legend/colour orderpalette="viridis",sizes=(20, 200)) # size range
Key takeaways
- 01Semantic mapping connects a data column to a visual channel (hue/size/style).
- 02A categorical hue gives distinct colours + legend; a numeric hue gives a gradient + colorbar.
- 03hue_order/size_order control category ordering; palette sets colours.
- 04These parameters are consistent across most Seaborn functions.
