size argument passed to annotations not respected?
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
I understand this issue has a chance of being an off-topic implementation issue. If so, please accept my sincere apologies in advance. Frank Harrell reported he is unable to change size of the annotated text using the code below.
require(plotly)
p <- plot_ly()
p <- add_markers(p,x=~1:2, y=~1:2)
p <- add_annotations(p, x=~c(1.1, 2.1), y=~c(1.2, 2.4),
text=~c('XXX','YYY'), size=~c(7,20))
p
I was unable to account for size of text using the 'old' method using 'layout' (as discussed in #744).
ann <- data.frame(x = c(1.1, 2.1),
y = c(1.2, 2.4),
size = c(10, 20),
text = c("XXX", "YYY"))
xy <- data.frame(x = c(1, 2), y = c(1, 2))
a <- vector("list", nrow(ann))
for (i in 1:nrow(ann)) {
a[[i]] <- list(
x = ann$x[i],
y = ann$y[i],
text = ann$text[i],
xref = "x", yref = "y",
showarrow = TRUE,
size = ann$size[i]
)
}
plot_ly(xy, x = ~x, y = ~y) %>%
add_markers() %>%
layout(annotations = a)
@cpsievert suggested using add_annotations but I'm a bit lost on how to pass on the size argument. Based on the documentation and some examples scattered over the internet, I tried
plot_ly(xy, x = ~x, y = ~y) %>%
add_markers() %>%
add_annotations(text = ~text, font = list(size = ~size), data = ann)
with no luck. Is there something I'm doing wrong?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先复现所提供的 add_annotations 示例,包括 font = list(size = ~size) 形式和较早的布局方式。跟踪 add_annotations 入口点,了解 annotation 的大小是如何传递的,然后验证 annotation 是否按照所请求的每行大小进行渲染。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100