plotly / plotly/plotly.R

Skinny boxes when using geom_boxplot and facet_wrap

Open
#2,178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

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")

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reproducible R example with geom_boxplot, facet_wrap, ggplotly, and layout(boxmode = "group"), then compare it with the non-faceted plot. Investigate the faceted boxplot conversion and verify that the boxes retain an appropriate width and visible color when the behavior is corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
plotly, r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.