plotly / plotly/plotly.R

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

未关闭
#1,957 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用 ggplotly() 和 geom_tile() 通过 R 示例复现该问题,将默认宽度和自定义宽度的情况与 geom_col() 的行为进行比较。跟踪 ggplotly() 对 tile 宽度的转换,并验证没有行的 x 值所对应的间隔仍为空,同时确认 geom_tile(width = .5) 得到遵循。

由索引模型根据 Issue 内容生成。

评估

技术栈
r
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。