Annotations for factor in barplot misplaced
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
When adding annotations to a barplot with x as factor, the plot gets squished
Problem arises since R plotly version 4.10.1. Worked fine until plotly 4.9.2.1
This works not
plotData <- data.frame(x = factor(1991:2000), y = rnorm(10))
plot_ly(data = plotData, x = ~x, y = ~y, type = "bar") %>%
layout(annotations = list(x = plotData$x, y = 0, text = 1:10))

This works, although it is safer to match on the actual x-values (factor levels) rather than on a numeric variant (mind the -1 to get it start at 0!)
plotData <- data.frame(x = factor(1991:2000), y = rnorm(10))
plot_ly(data = plotData, x = ~x, y = ~y, type = "bar") %>%
layout(annotations = list(x = as.numeric(plotData$x) - 1, y = 0, text = 1:10))

贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从使用 factor 类型 x 值的 plot_ly() 和 layout(annotations = ...) 提供的复现开始,比较 plotly.R 4.9.2.1 与 4.10.1 之间的行为。跟踪 factor 注释的转换方式,并验证注释在不要求数值 factor 值的情况下仍与条形图类别保持对齐。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100