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)))
Using R
's ggplot2
:
library(ggplot2)
ggplot(data = df, aes(x = group, y = val, color = group)) + geom_violin()
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)
Where group "C" gets an inflated/artificial violin.
Any idea how to deal with this and not by using ggplotly
?