ggplotly does not respect the `width` of tiles, fills the "no data" range instead
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
ggplotly does not respect the width value used for tiles. In the examples, the tiles should have a constant width, but converting the visualisation with ggplotly() results in a different visualisation, in which the areas with no data associated are "filled in" by the bordering tiles. It looks like the tiles expand on both sides equally, just enough to fill the empty space.
Note that what is meant by "no data" here is different to "missing data": the x value has no corresponding row in the dataset.
library(ggplot2)
library(plotly)
# default tile width
(default_width <- ggplot(mapping = aes(x = c(1, 2, 4), y = 1, fill = 1:3)) +
geom_tile())

Convert to plotly:
ggplotly(default_width)

If one provides a custom width for the tiles, ggplotly() still ignores it:
# custom tile width
(custom_width <- ggplot(mapping = aes(x = c(1, 2, 4), y = 1, fill = 1:3)) +
geom_tile(width = .5))

Convert to plotly:
ggplotly(custom_width)

This does not happen if doing something similar with geom_col().
Using:
- R 4.1.0
- ggplot2 3.3.3
- plotly 4.9.3
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
Reproduce the issue with the R examples using ggplotly() and geom_tile(), comparing the default and custom width cases with the geom_col() behavior. Trace the ggplotly() conversion of tile widths and verify that gaps for x values without rows remain empty and that geom_tile(width = .5) is respected.
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