plotly / plotly/plotly.R

Improper alignment of boxplots in facets

Open
#697 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,
first of all, thanks for a great package!
I have spent some time with it recently and I think that I have found a bug. If I use boxplots and facets, the boxplots in the upper facet are on the left side of the category while the boxplots in the bottom facet are on the right side of the category, while I believe that they should be aligned in the middle. Picture tells more than thousands words, so see bellow...

you can get it with the following code:

library(ggplot2)
library(plotly)

data.1 <- diamonds
data.1$set <- "set1"

data.2 <- data.1
data.2$set <- "set2"

my.data <- rbind(data.1, data.2)

p <- ggplot(my.data, aes(x=cut, y=price, fill= clarity))+
  geom_boxplot()+
  facet_grid(set ~ .)

ggplotly(p)%>%
  layout(boxmode = "group")

boxplots

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 with the supplied ggplot2 and ggplotly reproduction, focusing on how faceted boxplots are converted and positioned. Recreate the example and verify that boxplots in both facets are centered on their categories while preserving grouped layout behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.