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

Not able to customise legends for histplots #2632

Closed
shivendra90 opened this issue Aug 5, 2021 · 1 comment
Closed

Not able to customise legends for histplots #2632

shivendra90 opened this issue Aug 5, 2021 · 1 comment

Comments

@shivendra90
Copy link

shivendra90 commented Aug 5, 2021

In seaborn, it seems one cannot customise legends for histplots. I'm not sure about the other categorical plots, but it is possible for scatter plots.

# This works
f, ax = pt.subplots()

x = np.arange(0, 6)
y1 = np.random.randint(1, 50, 6)
y2 = np.random.randomint(1, 25, 6)

sns.scatterplot(x=x, y=y1, color="blue", ax=ax)
sns.scatterplot(x=x, y=y2, color="red", ax=ax)
ax.legend(fontsize="medium")
plt.show()

# This does not work
f, ax = plt.subplots()

sns.histplot(x=x, y=y1, ax=ax)
sns.histplot(x=x, y=y2, ax=ax)
ax.legend(fontsize="medium")

For hisplots, I get the error No handles with labels found to put in legend. Any way to have ax.legend function properly?

@mwaskom
Copy link
Owner

mwaskom commented Aug 5, 2021

Duplicate of #2280

@mwaskom mwaskom marked this as a duplicate of #2280 Aug 5, 2021
@mwaskom mwaskom closed this as completed Aug 5, 2021
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