plotly / plotly/plotly.R

`updatemenus` > `buttons` don't behave as expected when restyling `y` axis (ignores `color` channel)

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

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

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

説明

library(plotly)

dat <- structure(list(date = structure(c(1230768000, 1230771600, 1230775200, 
  1230778800, 1230782400, 1230786000, 1230789600, 1230793200, 1230796800, 
  1230800400, 1230768000, 1230771600, 1230775200, 1230778800, 1230782400, 
  1230786000, 1230789600, 1230793200, 1230796800, 1230800400, 1230768000, 
  1230771600, 1230775200, 1230778800, 1230782400, 1230786000, 1230789600, 
  1230793200, 1230796800, 1230800400, 1230768000, 1230771600, 1230775200, 
  1230778800, 1230782400, 1230786000, 1230789600, 1230793200, 1230796800, 
  1230800400), tzone = "GMT", class = c("POSIXct", "POSIXt")), 
      nox = c(113, 40, 48, 36, 40, 50, 50, 53, 80, 111, NA, NA, 
      NA, NA, NA, NA, NA, NA, NA, NA, 130, 63, 76, 69, 61, 61, 
      61, 92, 57, 50, 31, 34, 27, 19, 21, 25, 19, 31, 42, 48), 
      pm10 = c(46, 49, 46, NA, 38, 32, 36, 32, 30, 32, NA, NA, 
      NA, NA, NA, NA, NA, NA, NA, NA, 53, 46, 45, 43, 37, 35, 37, 
      38, 33, 31, 44, 39, 40, 35, 34, 30, 28, 31, 29, 27), site = structure(c(1L, 
      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
      2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 
      4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), levels = c("1", "2", 
      "3", "4"), class = "factor")), row.names = c(NA, -40L), class = c("tbl_df", 
  "tbl", "data.frame"))

plot_ly(x = dat$date, y = dat$nox) |>
  add_lines(color = dat$site) |>
  layout(updatemenus = list(list(
    type = "buttons",
    y = 0.8,
    buttons = list(
      list(
        method = "restyle",
        args = list("y", list(dat$nox)),
        label = "NO<sub>x</sub>"
      ),
      list(
        method = "restyle",
        args = list("y", list(dat$pm10)),
        label = "PM<sub>10</sub>"
      )
    )
  )))

I would imagine that clicking the "NOx" button would do effectively nothing, but instead it seems to strip away the color feature of the plot.

Before clicking:

image

After clicking:

image

Am I doing something wrong, or is this a bug?

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

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

はじめの一歩

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

調査の方向性

まず、提供された R の再現コードを plot_ly()、add_lines(color = dat$site)、および y に対して restyle を呼び出す layout updatemenus ボタンとともに実行します。その restyle が色付きのトレースにどのような影響を与えるかを追跡します。完了の条件は、NOx と PM10 を切り替えると y データが変更され、site の色によるグループ化が削除されないことです。

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

評価

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

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

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