plotly / plotly/plotly.R

frame in `ggplotly` not working when taking a `Date` object

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

还没有人认领这个 Issue。

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

描述

Hi Carson,

The new animation feature is awesome. But I run into an issue when the frame arg takes a Date object, and I need to convert to numerics. Please see the little reproducible example below:

library(plotly)
df <- data.frame(
  Date = seq(as.Date("2017-01-01"), as.Date("2017-01-05"), by = 1),
  Hour = rep(1:24, 5),
  Value = rnorm(24 * 5)
)
p1 <- ggplot(aes(Hour, Value, frame = Date), data = df) +
  geom_line() # not working
ggplotly(p1)
p2 <- ggplot(aes(Hour, Value, frame = as.numeric(Date)), data = df) +
  geom_line() # working
ggplotly(p2)

Thanks a lot,
Earo

贡献指南

打开贡献指南

从这里开始

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

调研方向

运行 issue 中可复现的 R 示例,并比较 frame 使用 Date 的 ggplotly(p1) 与使用 as.numeric(Date) 的 ggplotly(p2)。从 ggplotly 对 frame aesthetic 的处理入手,追踪 Date 值的转换过程。当使用 Date 值的 frame 无需手动进行数值转换即可正常工作,且现有的数值情况仍能正常工作时,即可视为完成。

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

评估

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

把新 issue 发到你的邮箱

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