ggplotly date shows wrong when use geom_bar(stat='count')
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
I find a problem that, when I use geom_bar(stat='count') to draw a plot and convert to plotly, when pointing to, the label shows date an integer, but when I aggregate the data first and use geom_bar(stat='identity'), the label shows date in proper format. The issue happened after I update to MRO 3.4.1, and try to solve the problem that ggplotly makes graph empty when x axis is date. I update both ggplot2 and plotly to github version that empty problem is gone, but new problem comes.
By the way. Is there a method that control the date format in the label?
devtools::install_github("hadley/ggplot2")
devtools::install_github("ropensci/plotly")
library(ggplot2)
library(plotly)
df2 = data.frame(time = c('2017-01-01 06:00:23', '2017-01-01 10:00:23',
'2017-01-01 18:00:23', '2017-01-01 24:00:23',
'2017-01-02 06:00:23', '2017-01-02 10:00:23',
'2017-01-02 18:00:23', '2017-01-03 24:00:23'),
y = c(1:8))
df2.p = ggplot(df2 %>% mutate(date_id = as.Date(time)), aes(x = date_id, y = ..count..)) +
geom_bar(stat = 'count')
ggplotly(df2.p)
df3 = df2 %>% mutate(date_id = as.Date(time)) %>%
group_by(date_id) %>% summarise(
count = n()
)
df3.p = ggplot(df3, aes(x = date_id, y = count)) +
geom_bar(stat = 'identity')
ggplotly(df3.p)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中可复现的 R 示例开始,并比较 geom_bar(stat='count') 与 stat='identity' 版本的 ggplotly 输出。调查 date_id aesthetic 在每次转换中的表示方式;完成的标准是基于计数的条形图显示格式正确的日期标签,并明确任何日期格式化行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100