Skip to content

Adding size=X to sns.scatterplot adds an entry to the legend (as well as changing the pointsize) #3482

Description

@beyarkay

Minimum working example:

import numpy as np
import seaborn as sns
import pandas as pd

data = pd.DataFrame()
data['x'] = np.random.random((100,))
data['y'] = np.random.random((100,))
data['hue'] = np.random.choice(['hue1', 'hue2', 'hue3'], (100,))
sns.scatterplot(
    data=data,
    x='x',
    y='y',
    hue='hue',
    size=1,
)

Result:

Screenshot 2023-09-18 at 12 08 14

I'm not entirely sure what's going on here, and it's possible that it's an error on my part. There seems to be many different types of behaviour depending on the usage of hue, size, and s:

sns.scatterplot(..., size=1, ...) (item added to legend)

size equals 1

sns.scatterplot(..., hue='hue', size=1, ...) (item added to legend)

Screenshot 2023-09-18 at 12 14 53

sns.scatterplot(..., hue='hue', s=1, ...) (no extra legend item)

Screenshot 2023-09-18 at 12 15 16

sns.scatterplot(..., hue='hue', ...)(no extra legend item)

Screenshot 2023-09-18 at 12 15 05

I'd expect that adding size=1 would not add an item 1 to the legend. Not sure if this is a bug or if I'm using the interface wrong though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions