plotly / plotly/plotly.R

ggplotly does not respect the `width` of tiles, fills the "no data" range instead

Open
#1,957 1 comment 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

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)

default

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)

custom

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.