Skip to content

relplot fails with empty dataset and a style argument #3870

@alexarntzen

Description

@alexarntzen

relplot fails when when passed an empty DataFrame and a style argument on seaborn==0.13.2. The error is not present in seaborn==0.12.2, and broke my pipeline when upgrading.

Example:

import pandas as pd
import seaborn as sns

empty_df = pd.DataFrame(columns=["x", "y", "style"])

sns.relplot(empty_df, x="x", y="y", style="style")

Output:

TypeError: 'NoneType' object is not iterable

Environment:

python==3.11.12
numpy==2.3.2
pandas==2.3.2
seaborn==0.13.2
matplotlib==3.10.6

Reason for error:

The error occurs because a check for style_order being None is missing from:

markers = {k: p._style_map(k, "marker") for k in style_order}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions