-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add split palette and hatching to violinplot? #2027
Comments
I would like to have more hatching in seaborn, however, hatches are kind of broken in matplotlib, both in terms of the API for controlling hatches and their implementation in some of the vector backends. I wouldn't want to add more options for hatching until that improves and stabilizes. I don't think the |
There are many github issues about hatching if you want to read more; here is at least one that I know of because I opened it: matplotlib/matplotlib#11418 |
By the way here is a method for adding hatches without hacking/extending the violinplot function itself: import seaborn as sns
import matplotlib as mpl
tips = sns.load_dataset("tips")
ax = sns.violinplot(x="day", y="total_bill", hue="sex", data=tips, split=True)
for i, violin in enumerate(ax.findobj(mpl.collections.PolyCollection)):
if i % 2:
violin.set_hatch("//")
ax.legend_.findobj(mpl.patches.Rectangle)[1].set_hatch("///") |
True, although it would be an optional keyword set to the current behaviour by default.
Fair enough! That seems to be a no to both changes here, so I'll close the issue.
Thanks for that, I did look around for the magic way to get the violin objects but focused on methods that started with |
This didn't work completely for me, but instead I used: |
Hi Seaborn devs,
I modified the violinplot for more flexible palette colouring and hatching when data is split by hue. Would you be interested in adding this functionality to violinplot? If so, I'd be happy to clean it up and make a PR.
Edit: to clarify, there is currently no way to colour by x-axis category when the
hue
keyword is given, and no current way to add hatching to any of the fills. The modifications are two new keywords,hatch=None
andsplit_palette=False
.The text was updated successfully, but these errors were encountered: