Skip to main content
Albero Academy

Scatter Plots

Relationships between two variables, with grouping baked in.

Relational Plots9 min

sns.scatterplot shows the relationship between two numeric variables — like Matplotlib's scatter, but with grouping by a third (or fourth) variable built in via hue, size and style.

Basic scatter

data + column names
sns.scatterplot(data=tips, x="total_bill", y="tip")

Grouping with hue/size/style

These map extra columns to visual channels automatically — colour, marker size, marker shape — with a legend:

four variables at once
sns.scatterplot(
data=tips, x="total_bill", y="tip",
hue="time", # colour by lunch/dinner
size="size", # marker size by party size
style="smoker", # marker shape by smoker
)

Key takeaways

  1. 01sns.scatterplot(data=, x=, y=) shows relationships between two variables.
  2. 02hue colours points by a column; size scales them; style changes the marker.
  3. 03Seaborn builds the legend automatically from those mappings.
  4. 04You can encode up to four variables on one scatter.

Finished this chapter?

Mark it complete to track your progress through Seaborn.