plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

Skinny boxes when using geom_boxplot and facet_wrap

Open angeloBartsch opened this issue 3 years ago • 0 comments

When using facet_wrap with geom_boxplot, the boxes are very thin, and their color is not seen. I tried adjusting the width but does not work. Without facet_wrap, the plot looks as expected

library(plyr)
library(reshape2)
library(plotly)
library(magrittr)

set.seed(1234)
x<- rnorm(100)
y.1<-rnorm(100)
y.2<-rnorm(100)
y.3<-rnorm(100)
y.4<-rnorm(100)

df<- (as.data.frame(cbind(x,y.1,y.2,y.3,y.4)))

dfmelt<-cbind(melt(df, measure.vars = 2:5),rep(c("A","B"),each=50)) %>% `colnames<-`(c("x","variable","value","Group"))
p<-ggplot(dfmelt, aes(x=factor(round_any(x,0.5)), y=value,fill=variable)) + geom_boxplot()+
  facet_wrap(~Group)
ggplotly(p)%>%layout(boxmode = "group")

angeloBartsch avatar Aug 31 '22 21:08 angeloBartsch