Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

histplot legend: No handles with labels found to put in legend #2432

Closed
trenton3983 opened this issue Jan 12, 2021 · 2 comments
Closed

histplot legend: No handles with labels found to put in legend #2432

trenton3983 opened this issue Jan 12, 2021 · 2 comments

Comments

@trenton3983
Copy link

I'm trying to move the legend for a sns.histplot

import seaborn as sns
import pandas as pd
import numpy as np  # for test data
import random  # for test data
import calendar  # for test data

# test dataframe
np.random.seed(365)
random.seed(365)
df = pd.DataFrame({'Days': random.choices(calendar.day_name, k=1000), 'Visitors': np.random.randint(1, 121, size=(1000))})

ax = sns.histplot(data=df, x='Visitors', hue='Days', multiple="stack")
ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left')

image

  • Without trying to move the legend
    image

  • Moving the legend in this way works fine with sns.barplot

ax = sns.barplot(data=df, x='Days', y='Visitors', hue='Days', dodge=False, estimator=sum)
ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left')

image

@mwaskom
Copy link
Owner

mwaskom commented Jan 12, 2021

Duplicate of #2280 which has a workaround and links to some broader context.

@mwaskom mwaskom closed this as completed Jan 12, 2021
@trenton3983
Copy link
Author

Thanks Michael. I searched, but didn't see it. Best Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants