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

sns.relplot() legend not showing marker 'x', '+', '1', '2' etc. #3686

Open
adrbmdns opened this issue May 1, 2024 · 2 comments
Open

sns.relplot() legend not showing marker 'x', '+', '1', '2' etc. #3686

adrbmdns opened this issue May 1, 2024 · 2 comments

Comments

@adrbmdns
Copy link

adrbmdns commented May 1, 2024

This code is from the seaborn tutorial - An introduction to seaborn.

sns.set_theme(style="ticks", font_scale=1.25)
g = sns.relplot(
    data=penguins,
    x="bill_length_mm", y="bill_depth_mm", hue="body_mass_g",
    palette="crest", marker="x", s=100,
)
g.set_axis_labels("Bill length (mm)", "Bill depth (mm)", labelpad=10)
g.legend.set_title("Body mass (g)")
g.figure.set_size_inches(6.5, 4.5)
g.ax.margins(.15)
g.despine(trim=True)

image

In the legend, it doesn't show the marker handle.

But when I change to solid markers marker="." and marker="X", it will show the marker handle in legend. See,

output

@mwaskom
Copy link
Owner

mwaskom commented May 1, 2024

Thanks for reporting, hm, looks like the legend artists are inheriting a zero marker edgewidth from somewhere. You can fix it by doing

plt.setp(g.legend.legend_handles, markeredgewidth=1)

@adrbmdns
Copy link
Author

adrbmdns commented May 1, 2024

Thanks for responding this quick. The solution works!

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