plotly.R
plotly.R copied to clipboard
Skinny boxes when using geom_boxplot and facet_wrap
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")