Skip to content

Force plotly violin plot not to display a violin on zero values #1476

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

Closed
ndrubins opened this issue Mar 5, 2019 · 1 comment
Closed

Force plotly violin plot not to display a violin on zero values #1476

ndrubins opened this issue Mar 5, 2019 · 1 comment

Comments

@ndrubins
Copy link

ndrubins commented Mar 5, 2019

Hi,

I have measurements from several groups which I would like to plot as violin plots:

  set.seed(1)
   df <- data.frame(val = c(runif(100,1,5),runif(100,1,5),rep(0,100)),
                    group = c(rep("A",100),rep("B",100),rep("C",100)))


When I use R's ggplot2:

    library(ggplot2)
    ggplot(data = df, aes(x = group, y = val, color = group)) + geom_violin()

I get this plot

But when I try to get the equivalent with R's plotly using:

    library(plotly)
    plot_ly(x = df$group, y = df$val, split = df$group, type = 'violin', box = list(visible = F), points = F, showlegend = T, color = df$group)

I get this plot in which group "C" gets an inflated/artificial violin.

Can I tell plot_ly not to create violin for groups such as "C"?

@cpsievert
Copy link
Collaborator

This is something that should be fixed at the plotly.js level, see plotly/plotly.js#2779

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

No branches or pull requests

2 participants