Skip to content

lineplot not working when hue changes along units #3866

@RobinSobczyk

Description

@RobinSobczyk

Hi, I'd like to highlight that seaborn does not handle hue grouping when the hue variable is not constant inside units. Here is a MWE :

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

df_data = []
for i in range(5):
    for j in range(5):
        df_data.append(
            {
                "Traj_id": i,
                "Step_id": j,
                "X": np.random.random(),
                "Y": np.random.random(),
            }
        )
df = pd.DataFrame(df_data)
sns.lineplot(
    data=df,
    x="X",
    y="Y",
    hue="Step_id",
    markers=True,
    sort=False,
    units="Traj_id",
    estimator=None,  # type: ignore
)
plt.show()

What is expected is color changing along the trajectories, but all I get is a blank figure (with a legend though) without getting any warning or error.
Could be interesting to have this feature to plot trajectory tendencies depending on step conditions.

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