plotly / plotly/plotly.R

Cannot have more than one shape after subplot()

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

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

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

説明

I guess this is related to #1333

Here is the issue: it doesn't seem possible to have more than one shape after subplot() is called. Applying the shapes to the individual plots work, though.

reprex that works:

library(plotly)

p1 <- plot_ly(mtcars, x = ~mpg, y = ~hp) %>% 
  layout(
    shapes = list(
      list(
        type = "line", 
        line = list(color = "#5681c4", dash = "dot"),
        x0 = 20, 
        x1 = 20,
        y0 = 0,
        y1 = 1,
        yref = "paper"
      ),
      list(
        type = "line", 
        line = list(color = "#5681c4", dash = "solid"),
        x0 = 30, 
        x1 = 30,
        y0 = 0,
        y1 = 1,
        yref = "paper"
      )
    )
  ) %>%
  config(editable = TRUE)

p2 <- plot_ly(mtcars, x = ~mpg, y = ~drat) %>% 
  layout(
    shapes = list(
      list(
        type = "line", 
        line = list(color = "#5681c4", dash = "dot"),
        x0 = 20, 
        x1 = 20,
        y0 = 0,
        y1 = 1,
        yref = "paper"
      ),
      list(
        type = "line", 
        line = list(color = "#5681c4", dash = "solid"),
        x0 = 30, 
        x1 = 30,
        y0 = 0,
        y1 = 1,
        yref = "paper"
      )
    )
  ) %>%
  config(editable = TRUE)

subplot(p1, p2, nrows = 2)

reprex that does not work:

library(plotly)

p1 <- plot_ly(mtcars, x = ~mpg, y = ~hp)

p2 <- plot_ly(mtcars, x = ~mpg, y = ~drat)

subplot(p1, p2, nrows = 2) %>% 
  layout(
    shapes = list(
      list(
        type = "line", 
        line = list(color = "#5681c4", dash = "dot"),
        x0 = 20, 
        x1 = 20,
        y0 = 0,
        y1 = 1,
        yref = "paper"
      ),
      list(
        type = "line", 
        line = list(color = "#5681c4", dash = "solid"),
        x0 = 30, 
        x1 = 30,
        y0 = 0,
        y1 = 1,
        yref = "paper"
      )
    )
  ) %>%
  config(editable = TRUE)

reprex with only one shape - it works:

library(plotly)

p1 <- plot_ly(mtcars, x = ~mpg, y = ~hp)

p2 <- plot_ly(mtcars, x = ~mpg, y = ~drat)

subplot(p1, p2, nrows = 2) %>% 
  layout(
    shapes = list(
      type = "line", 
      line = list(color = "#5681c4", dash = "dot"),
      x0 = 20, 
      x1 = 20,
      y0 = 0,
      y1 = 1,
      yref = "paper"
    )
  ) %>%
  config(editable = TRUE)

Any thoughts?

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

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

はじめの一歩

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

調査の方向性

まず issue 内の動作する reprex と失敗する reprex を実行し、各 plot に渡される shapes と subplot() の後に追加される shapes を比較します。subplot() がどのように plot を結合し、その後の layout(shapes = ...) の呼び出しがどのように処理されるかを追跡します。両方の shapes が subplot 上にレンダリングされ、config(editable = TRUE) で編集可能な状態を維持できれば完了です。

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

評価

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

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

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