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

Add dodging to violin plots that call :color #1635

Open
hbsmith opened this issue Oct 21, 2024 · 1 comment
Open

Add dodging to violin plots that call :color #1635

hbsmith opened this issue Oct 21, 2024 · 1 comment

Comments

@hbsmith
Copy link

hbsmith commented Oct 21, 2024

I'm trying to make violin plot versions of the boxplots which are displayed as p2 here: https://gadflyjl.org/stable/gallery/geometries/#[Geom.boxplot](@ref)
image

My expectation is that :color in a violin plot would would like it does in a boxplot, but it does not. If I want to plot two different categories using a violin plot, where both categories have the same x-axis, it does not work. I'd expect it to apply dodge to the datasets. After digging, it seems like there is no option to even have violin plot dodge.

Basically, I want to make the same kind of plot that seaborn demonstrates here: https://seaborn.pydata.org/generated/seaborn.violinplot.html
sns.violinplot(data=df, x="class", y="age", hue="alive")
image

Is there a way to do this that I'm not aware of?

@Mattriks
Copy link
Member

Yes the dodge effect isn't implemented yet for Geom.violin, and we're happy to see PRs! A possible workaound is:

plot(salaries, x=:Rank, y=:Salary, color=:Rank,
    xgroup=:Discipline,
    Geom.subplot_grid(Geom.violin),
    Scale.xgroup(levels=["Discipline A", "Discipline B"]),
    Guide.xlabel(nothing)
)

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