boxplots are always placed below other geometries regardless of order
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Hi there
I noticed that with ggplotly() taking a ggplot object, the layering of geometries is not respected by boxplots, which always end up underneath everything else (in my testing at least).
See this reprex:
library(ggplot2)
bp <- ggplot(mpg, aes(x = class, y = hwy)) +
geom_jitter(colour = "orange") +
geom_boxplot()
# jitter is below boxplots
bp

# ggplotly puts boxplot underneath everything else
library(plotly)
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
ggplotly(bp)
#> TypeError: Attempting to change the setter of an unconfigurable property.
#> TypeError: Attempting to change the setter of an unconfigurable property.

Created on 2020-08-19 by the reprex package (v0.3.0)
Interestingly, the TypeError doesn't show up in my console, but it does in the reprex output.
Using R 4.0.2 on Ubuntu 18.04 with RStudio 1.3.1073, ggplot2 3.3.2 and plotly 4.9.2.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reported ggplotly(bp) reprex with the stated R, ggplot2, and plotly versions, then compare the ggplot and rendered layer order. Done means boxplots respect the geometry order and the reported TypeError no longer occurs in the reprex output.
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
- 35/100