size argument passed to annotations not respected?
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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?
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện các ví dụ add_annotations được cung cấp, bao gồm dạng font = list(size = ~size) và cách tiếp cận layout cũ hơn. Theo dõi entry point add_annotations để xem kích thước của annotation được truyền như thế nào, sau đó xác minh rằng các annotation được render với kích thước theo từng hàng được yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- r
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100