plotly / plotly/plotly.R

subplot() not producing the interactive equivalent of gridExtra::grid.arrange()

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

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

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

説明

Given:

    library(ggplot2)
    library(gridExtra)
    library(plotly)
    library(colorRamps)
    
    d <- data.frame(x=sample(1:10)/10, y=sample(1:10)/10, z=sample(1:10)/10, c=sample(LETTERS[1:5],size=10,replace=TRUE))
    g1 <- ggplot(d) +
      geom_point(aes(x=x, y=y, fill = z),
                 pch=21,size=4) +
      facet_wrap(~c,labeller = label_both) +
      scale_fill_gradientn(colors = matlab.like2(16),limits=c(0, 100)) +
      xlim(c(0,1)) + ylim(c(0,1)) +
      coord_fixed(ratio = 1) +
      theme(legend.position=c(0.85,0.2), legend.background=element_blank()) +
      labs(fill = "%")
    
    g2<- g1+ggtitle("Plot 2")
    g3<- g1+gtitle("Plot 3")
    g4<- g1+ggtitle("Plot 4")
    g1<- g1+ggtitle("Plot 1")
    p = list(g1,g2,g3,g4) %>% map(~.x + labs(x=NULL, y=NULL))
    yleft= "X"
    xbottom= "Y"
    grid.arrange(grobs=p,bottom = xbottom, left = yleft,nrow=2)

Image

I want to get the same plot but with interactive browsing of the values. I try:

pg1 <- ggplotly(g1)
pg2 <- ggplotly(g2)
pg3 <- ggplotly(g3)
pg4 <- ggplotly(g4)

Individual plots are ok:

pg1

Image

But

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=FALSE, shareY=FALSE,titleX=TRUE,titleY=TRUE)

or

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=FALSE, shareY=FALSE,titleX=FALSE,titleY=FALSE)

result into:

Image

Which is almost good but displays only 1 title (and in the wrong place) and no axes titles.

I try

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=TRUE, shareY=TRUE,titleX=FALSE,titleY=FALSE)

and

subplot(list(pg1, pg2,pg3,pg4), nrows=2, 
        shareX=TRUE, shareY=TRUE,titleX=TRUE,titleY=TRUE)

and the result is even worse:

Image

Is this a bug or am I doing something wrong? Is there an alternative way to get the interactive version of the grid?

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

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

はじめの一歩

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

調査の方向性

issue で再現されている ggplotly() と subplot() の呼び出しから始め、それらの出力を grid.arrange() と比較します。subplot() が複数のプロットタイトル、共有軸、軸タイトルをどのように扱うかを追跡します。4つの変換後のプロットが、2行のインタラクティブな配置で期待されるタイトルと軸を保持するか、またはその挙動が制限事項として文書化されれば完了です。

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

評価

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

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

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