plotly / plotly/plotly.R

Data gets dropped in add_trace and consequently points have the wrong color if NA is present

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

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

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

説明

Have a look at the following code:

library(plotly)
x = c(NA, 2, 3, 4, 5)
color = c(0, 0, 0.5, 1, 1)
# If you try to plot it this way, you get mismatched colors. The NA seems to have been silently dropped and then the wrong indices aligned. The colors of points 2 and 3 are now blue, of 4 is purple and of 5 is green.
plotly::plot_ly()|>
    plotly::add_trace(
      type = "scatter",
      mode = "markers",
      x = x,
      y = 0,
      marker = list(
        color = color,
        cmin = 0,
        cmax = 1,
        colorscale = list(list(0, "blue"), list(0.5, "purple"), list(1, "green"))
      )
    ) |>
    plotly::layout(
      showlegend = FALSE
    ) |>
    plotly::hide_colorbar() 

It produces a plot with wrong colors:

Image

I think this is unacceptable behavior, especially since this is not what happens if you do it in the what I consider the classical way:

data.frame(x=x, color=color) |> 
  plot_ly(x=~x, color=~color, y=0, colors = c("blue", "purple", "green")) |> 
  hide_colorbar()
Image

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

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

はじめの一歩

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

調査の方向性

提供された R の例を plotly::add_trace に通して実行し、マーカーの色を data.frame の例と比較します。add_trace が x の NA 値をどのように処理し、マーカーの色ベクトルをどのように整列させるかを追跡し、NA でない点が対応する色を保持することを示すリグレッションカバレッジを追加します。

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

評価

技術スタック
r
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
72/100

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

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