plotly / plotly/plotly.R

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

オープン
#2,069 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

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")


コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された R の再現コードを実行し、add_paths の後に heatmap 単体を ht_a1、ht_a2、ht_a3 と比較します。別のレイヤーを追加したときに heatmap のラベルと hoverinfo がどのように動作するかを追跡します。完了の条件は、2 つの workaround のいずれも必要とせず、元の heatmap のラベルが表示されたままになることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
r
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。