# Seaborn Scatter Plot: sns.scatterplot() with hue, size, and style

> Make a Seaborn scatter plot with sns.scatterplot(data=df, x="a", y="b", hue="group"). Covers hue, palette, size, style, alpha for overlap, legends, titles, labels, and relplot facets.

Source: https://www.pythoncharts.com/seaborn/seaborn-scatterplot/ | Published: 2026-12-05 | Author: Alex Scott | Category: Seaborn | Tags: seaborn, scatterplot, scatter, relplot, hue

To make a scatter plot in Seaborn, call `sns.scatterplot(data=df, x="col_a", y="col_b")`. Add `hue="group"` to color points by a column, `size=` to scale them by a number, and `style=` to change the marker shape. It returns a Matplotlib `Axes`, so titles and axis labels are set with `ax.set()`. The examples use Seaborn 0.13.

## Quick Example

```python
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns

rng = np.random.default_rng(41)
n = 240
districts = rng.choice(["Old Town", "Riverside", "Hillcrest"], n, p=[0.3, 0.4, 0.3])
bedrooms = rng.choice([1, 2, 3], n, p=[0.4, 0.4, 0.2])
area = 28 + 22 * bedrooms + rng.normal(0, 9, n)
price_per_m2 = pd.Series(districts).map({"Old Town": 24, "Riverside": 19, "Hillcrest": 15})
flats = pd.DataFrame({
    "district": districts,
    "bedrooms": bedrooms,
    "area": area.round(),
    "rent": (area * price_per_m2 + rng.normal(0, 120, n)).round(-1),
    "building_age": np.where(districts == "Old Town", rng.integers(40, 120, n),
                             rng.integers(0, 60, n)),
})

sns.set_theme(style="whitegrid")
fig, ax = plt.subplots(figsize=(8, 5))
sns.scatterplot(data=flats, x="area", y="rent", hue="district", alpha=0.8, ax=ax)
ax.set(title="Monthly rent by floor area", xlabel="Floor area (m²)", ylabel="Rent (€)")
plt.show()
```

![Seaborn scatter plot of monthly rent against floor area for 240 flats colored by district: rent rises with area in all three districts, at a median of about €24 per square meter in Old Town, €19 in Riverside, and €15 in Hillcrest](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-quick-example.png)

Each row of `flats` is one point. Seaborn picks the colors, builds the legend from the `district` column, and labels the axes with the column names unless you override them, as `ax.set()` does here.

## How do I color points by a category?

`hue=` colors points by a column. With text columns, `palette=` picks the colors and `hue_order=` fixes their order in the legend:

```python
fig, ax = plt.subplots(figsize=(8, 5))
sns.scatterplot(
    data=flats, x="area", y="rent", hue="district",
    hue_order=["Hillcrest", "Riverside", "Old Town"],
    palette={"Hillcrest": "#2a9d8f", "Riverside": "#e9c46a", "Old Town": "#c8553d"},
    edgecolor="white", linewidth=0.5, s=45, ax=ax,
)
ax.set(xlabel="Floor area (m²)", ylabel="Rent (€)")
plt.show()
```

![The same rent scatter plot with Hillcrest in teal, Riverside in yellow, and Old Town in red, and the legend in that order](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-palette.png)

`palette=` takes a dictionary (category to color), a list, or a palette name such as `"Set2"` or `"colorblind"`. Keyword arguments that Seaborn doesn't use, like `s` (marker area in points²), `edgecolor`, and `linewidth`, go to Matplotlib's `ax.scatter()`. See [custom color palettes](https://www.pythoncharts.com/seaborn/seaborn-custom-color-palettes/) for building your own.

## How do I color points by a number?

When the `hue` column is numeric, Seaborn uses a continuous colormap and the legend shows a few sample values. `palette=` takes a colormap name and `hue_norm=` sets the range:

```python
fig, ax = plt.subplots(figsize=(8, 5))
sns.scatterplot(data=flats, x="area", y="rent", hue="building_age",
                palette="viridis_r", hue_norm=(0, 120), ax=ax)
ax.set(xlabel="Floor area (m²)", ylabel="Rent (€)")
ax.legend(title="Building age (years)", loc="upper left")
plt.show()
```

![Rent scatter plot colored by building age with the viridis colormap, where new buildings are yellow and the oldest, in dark purple, are mostly the high-rent Old Town flats along the top](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-numeric-hue.png)

The `_r` suffix reverses a colormap, so new buildings are yellow and the oldest are dark purple. The dark points sit along the top: they're the Old Town flats, which cost the most per square meter. For a colorbar instead of a legend, pass `legend=False` and add one with Matplotlib:

```python
fig, ax = plt.subplots(figsize=(8, 5))
sns.scatterplot(data=flats, x="area", y="rent", hue="building_age",
                palette="viridis_r", hue_norm=(0, 120), legend=False, ax=ax)
norm = plt.Normalize(0, 120)
fig.colorbar(plt.cm.ScalarMappable(norm=norm, cmap="viridis_r"), ax=ax,
             label="Building age (years)")
ax.set(xlabel="Floor area (m²)", ylabel="Rent (€)")
plt.show()
```

![Rent scatter plot colored by building age with a vertical colorbar from 0 to 120 years on the right instead of a legend](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-colorbar.png)

The colorbar needs the same colormap and range as the points, which is why `hue_norm` and `Normalize` both use `(0, 120)`. The [Matplotlib colorbar guide](https://www.pythoncharts.com/matplotlib/matplotlib-colorbar/) covers the options.

## Change point size and marker with `size` and `style`

`size=` maps a column to marker area, and `sizes=(min, max)` sets the range in points². `style=` gives each category its own marker shape. Each adds its own section to the legend:

```python
fig, ax = plt.subplots(figsize=(8, 5))
sns.scatterplot(data=flats, x="area", y="rent", hue="district",
                size="bedrooms", sizes=(20, 160), style="bedrooms",
                alpha=0.75, ax=ax)
ax.set(xlabel="Floor area (m²)", ylabel="Rent (€)")
sns.move_legend(ax, "upper left", bbox_to_anchor=(1, 1), frameon=False)
plt.show()
```

![Rent scatter plot where color shows district, and both marker size and shape show bedrooms, with circles, crosses, and squares growing from one to three bedrooms, and the legend outside on the right](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-size-style.png)

Showing `bedrooms` twice (size and shape) is redundant on purpose: it's easier to read than size alone. With three encodings the legend gets long, so `sns.move_legend()` puts it outside the axes. To show circles of very different sizes, a [bubble chart](https://www.pythoncharts.com/matplotlib/matplotlib-bubble-chart/) in Matplotlib gives more control.

## How do I fix overlapping points?

With thousands of rows, points hide each other. Smaller, transparent markers without edges show where the data is dense:

```python
big = pd.DataFrame({"x": rng.normal(0, 1, 5000)})
big["y"] = 0.6 * big["x"] + rng.normal(0, 0.8, 5000)

fig, axs = plt.subplots(1, 2, figsize=(10, 4.5), sharey=True, layout="constrained")
sns.scatterplot(data=big, x="x", y="y", ax=axs[0])
axs[0].set_title("Default")
sns.scatterplot(data=big, x="x", y="y", s=6, alpha=0.25, linewidth=0, ax=axs[1])
axs[1].set_title("s=6, alpha=0.25, linewidth=0")
plt.show()
```

![Two scatter plots of the same 5,000 points: on the left the default markers merge into a solid blob, on the right small transparent markers show the dense center and the sparse edges](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-overplotting.png)

Past about 50,000 points, switch to a density view: `sns.histplot(data=big, x="x", y="y")` for a 2-D histogram, `sns.kdeplot` for contours, or a [hexbin plot](https://www.pythoncharts.com/matplotlib/matplotlib-hexbin-2d-histogram/).

## Split a scatter plot into panels with `relplot`

`sns.relplot()` is the figure-level version of `scatterplot`. It takes the same arguments plus `col=` and `row=`, and draws one panel per category:

```python
g = sns.relplot(data=flats, x="area", y="rent", hue="bedrooms", col="district",
                col_order=["Hillcrest", "Riverside", "Old Town"],
                palette="crest", height=3.6, aspect=0.9)
g.set_axis_labels("Floor area (m²)", "Rent (€)")
g.set_titles("{col_name}")
plt.show()
```

![Three scatter panels of rent against area for Hillcrest, Riverside, and Old Town, with points colored by bedroom count and the rent axis shared, showing Old Town rents climbing fastest with area](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-relplot.png)

`relplot` makes its own figure, so it ignores `ax=` and uses `height` and `aspect` instead of `figsize`. Use `g.set_titles()` and `g.figure.suptitle()` for titles; `g.set_title()` raises an `AttributeError`. See [figure-level vs axes-level functions](https://www.pythoncharts.com/seaborn/seaborn-figure-level-vs-axes-level/).

## How do I add a regression line or label points?

`sns.scatterplot` doesn't fit lines. Draw the points with `sns.regplot()` instead, which adds a fitted line and a confidence band, or `sns.lmplot()` for one line per `hue` group. See [regplot and lmplot](https://www.pythoncharts.com/seaborn/seaborn-regplot-lmplot/).

To label points, loop over the rows you want with `ax.annotate()`. Here the priciest flat in each district gets its rent:

```python
fig, ax = plt.subplots(figsize=(8, 5))
sns.scatterplot(data=flats, x="area", y="rent", hue="district", alpha=0.6, ax=ax)
priciest = flats.loc[flats.groupby("district")["rent"].idxmax()]
for row in priciest.itertuples():
    ax.annotate(f"€{row.rent:,.0f}", (row.area, row.rent),
                xytext=(-8, 0), textcoords="offset points", ha="right", va="center")
ax.set(xlabel="Floor area (m²)", ylabel="Rent (€)")
plt.show()
```

![Rent scatter plot with the priciest flat in each district labelled: €2,480 in Old Town, €2,340 in Riverside, and €1,780 in Hillcrest](https://www.pythoncharts.com/seaborn/seaborn-scatterplot/images/seaborn-scatterplot-annotate.png)

[Annotating data points](https://www.pythoncharts.com/matplotlib/matplotlib-annotate-data-points/) covers arrows and avoiding overlapping labels.

## `sns.scatterplot` vs `relplot`, `regplot`, and `plt.scatter`

| Use | When |
|---|---|
| `sns.scatterplot()` | One panel, colored or sized by columns, inside a Matplotlib figure you control (`ax=`) |
| `sns.relplot(kind="scatter")` | One panel per category with `col=` or `row=` |
| `sns.regplot()`, `sns.lmplot()` | You want a fitted line through the points |
| `sns.jointplot()` | You also want each variable's distribution on the margins ([joint plots](https://www.pythoncharts.com/seaborn/seaborn-jointplot-bivariate-distributions/)) |
| `sns.pairplot()` | Scatter plots of every pair of columns |
| `plt.scatter()` | Arrays rather than a DataFrame, or full control of each marker ([Matplotlib scatter plots](https://www.pythoncharts.com/matplotlib/matplotlib-scatterplot/)) |
| [Plotly Express `px.scatter()`](https://www.pythoncharts.com/plotly/plotly-scatter-plot/) | Readers need to hover over points |

## Common problems

| Problem | Fix |
|---|---|
| Legend covers the points | `sns.move_legend(ax, "upper left", bbox_to_anchor=(1, 1))`; see [move the legend](https://www.pythoncharts.com/seaborn/seaborn-move-legend/) |
| Legend shows only some numeric `hue` values | That's `legend="auto"`; pass `legend="full"` for every value, or use a colorbar |
| A numeric column like `bedrooms` gets a gradient | Convert it: `hue=flats["bedrooms"].astype(str)`, or pass a list `palette=` with one color per value |
| `figsize` or `ax=` is ignored | You called `relplot`; use `height` and `aspect`, or switch to `scatterplot` |
| Points stay one color with `c=` or `color=` | Seaborn ignores `c=`, and `color=` sets a single color for every point; color by a column with `hue=` |
| Points are hidden by others | `alpha=`, smaller `s=`, `linewidth=0`, or a density plot |

## Similar Topics

- [Scatter Plots in Matplotlib](https://www.pythoncharts.com/matplotlib/matplotlib-scatterplot/)
- [Seaborn regplot and lmplot: Regression Lines](https://www.pythoncharts.com/seaborn/seaborn-regplot-lmplot/)
- [How to Move the Legend in Seaborn (sns.move_legend)](https://www.pythoncharts.com/seaborn/seaborn-move-legend/)
