Unexpected behavior with geom_rect and ids arg in ggplotly()
未关闭
还没有人认领这个 Issue。
difficulty: high
ggplotly
priority: low
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Expected behavior demonstrated by geom_point. See ggplotly(gg1) below.
Unexpected behavior when using geom_rect with the ids arg across frames with changing number of observations. See ggplotly(gg2) and ggplotly(gg3) below.
### Win 10 x64, Rstudio
library(ggplot2) # ggplot2_3.0.0
library(plotly) # plotly_4.7.1
data(gapminder, package = "gapminder")
# filtering out some countries (soframes have differing number of obs)
sub_countries <- unique(gapminder$country)[1:10]
gapminder2 <- gapminder %>%
filter(((year != 1952) | (country %in% sub_countries)) & year < 1970)
# using geom_point (works)
gg1 <- ggplot(gapminder2) +
geom_point(aes(x = gdpPercap, y = lifeExp,
ids = country,
frame = year)) +
scale_x_log10()
ggplotly(gg1) # correct: sub, full, full, full
# using geom_rect (doesn't work with ids arg)
gg2 <- ggplot(gapminder2) +
geom_rect(aes(xmin = gdpPercap, ymin = lifeExp,
xmax = 1.05 * gdpPercap, ymax = 1.05 * lifeExp,
ids = country,
frame = year)) +
scale_x_log10()
ggplotly(gg2) # incorrect: sub, sub, sub, sub
# using geom_rect, subset on 2nd frame (doesn't work with ids arg)
gapminder3 <- gapminder %>%
filter(((year != 1957) | (country %in% sub_countries)) & year < 1970)
gg3 <- ggplot(gapminder3) +
geom_rect(aes(xmin = gdpPercap, ymin = lifeExp,
xmax = 1.05 * gdpPercap, ymax = 1.05 * lifeExp,
ids = country,
frame = year)) +
scale_x_log10()
ggplotly(gg3) # incorrect: full, sub moves, full, full
# frame year 1952 -> 1957 != 1962 -> 1957 != 1967 -> 1957
Cheers,
Nick
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 ggplot2 和 plotly 运行提供的 R 复现代码,比较观测数量发生变化时各帧中的 geom_point 和 geom_rect。跟踪 geom_rect、ids 和帧处理的 ggplotly 转换路径。当 geom_rect 在每一帧中都保留正确的观测值和 ids,并与演示的预期行为一致时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100