plotly / plotly/plotly.R

Some heatmap labels not visible when other layers added (e.g. with `add_trace`)

Đang mở
#2,069 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

Hi, thanks a lot for making such a great package :)!

I have the issue with labels. One can create a heatmap in plotly and see the labels (ht object). But once the new layer is added (e.g. with add_trace) the labels from the previous layer are not visible (ht_a1 object). Disabling labels from the second layer does not help (ht_a2 and ht_a3).

https://user-images.githubusercontent.com/41166437/140326488-f539949b-5baf-4e32-ad17-d3eb574cccf7.mp4

Both potential workaround are suboptimal (ht_a4 and ht_a5).

Thanks in advance for you help!

df <-
  data.frame(x = rep(1:10, 10),
             y = rep(1:10, each = 10),
             z = sample(1:100))
ht <-
  plotly::plot_ly(
    type = "heatmap",
    x = df$x,
    y = df$y,
    z = df$z
  )

# two layers: heatmap and single line
# some cells with heatmap labels (e.g. [2, 1], [1, 2], some with line labels (e.g. [1,1], [2,2]))
ldf <- data.frame(x = 1:8, y = c(1:5, 4:2))
ht_a1 <-
  plotly::add_paths(ht,
                    x = ldf$x,
                    y = ldf$y,
                    inherit = FALSE)

### disabling labels for single line does not enable labels for heatmap in related cells
ht_a2 <-
  plotly::add_paths(
    ht,
    x = ldf$x,
    y = ldf$y,
    inherit = FALSE,
    hoverinfo = "skip"
  )

ht_a3 <-
  plotly::add_paths(
    ht,
    x = ldf$x,
    y = ldf$y,
    inherit = FALSE,
    hoverinfo = "none"
  )
plotly::layout(ht_a3, hovermode="x")

## workaround #1 (restore labels from `heatmap` on the `line` layer)
ldf$z_idx <- ldf$x + 10 * (ldf$y - 1)
ldf$z <- df$z[ldf$z_idx]
ldf$label <- sprintf("x:%s\ny:%s\nz:%s", ldf$x, ldf$y, ldf$z)
ht_a4 <-
  plotly::add_paths(
    ht,
    x = ldf$x,
    y = ldf$y,
    inherit = FALSE,
    text = ldf$label,
    hoverinfo = "text"
  )

## workaround #2 (use with hovermode == "x")
# results in undesired behaviour (additional labels appearing)
ht_a5 <-
  plotly::add_paths(
    ht,
    x = ldf$x,
    y = ldf$y,
    inherit = FALSE,
    hoverinfo = "skip"
  ) %>% plotly::layout(hovermode = "x")


Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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 chạy bản tái hiện R được cung cấp và chỉ so sánh heatmap với ht_a1, ht_a2 và ht_a3 sau add_paths. Theo dõi cách các nhãn của heatmap và hoverinfo hoạt động khi thêm một layer khác; hoàn tất khi các nhãn heatmap ban đầu vẫn hiển thị mà không cần đến bất kỳ workaround nào trong hai workaround.

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ó
4/5
Thời gian dự kiến
3-5 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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.