plotly / plotly/plotly.R

Solution to combine facetted legends breaks for continuous variable

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

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

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

説明

I am trying to use plotly to create facetted plots - I do this by using group_map() to create my plots robustly.

The solution I currently have works in reducing duplicated legend labels when using discrete variables for color/size/etc but fail to work for continuous variables. I assume this is do to each facetted plot potentially having different total ranges for the continuous variable.

library(tidyverse)
library(plotly)

city_list = unique(txhousing$city) %>%  
  sample(8)

##solution works for discrete labels 
txhousing %>%  
  filter(month < 6, 
         city %in% city_list) %>% 
  group_by(month) %>% 
  group_map(~{
    plot_ly(.x, x=~year, y = ~sales, color = ~city,legendgroup = ~city,type = "bar"
            ,showlegend = (.y == "1")
            ) %>%
      layout(yaxis = list(
        title = paste0(c(rep("&nbsp;", 20),
                         paste("<b>", as.character(.y), "</b>"),
                         rep("&nbsp;", 20),
                         rep("\n&nbsp;", 3)),
                       collapse = ""))) %>%
      layout(barmode = 'stack')
  }
  ) %>%
  subplot(nrows = NROW(.), margin = .05, shareX = T, shareY = T, titleY = T) 

##solution fails to merge legends for continuous variable
txhousing %>%  
  filter(month < 6, 
         city %in% city_list) %>% 
  group_by(month) %>% 
  group_map(~{
    plot_ly(.x, x=~year, y = ~sales, color = ~volume,legendgroup = ~volume,type = "bar"
            ,showlegend = (.y == "1")
            ) %>%
      layout(yaxis = list(
        title = paste0(c(rep("&nbsp;", 20),
                         paste("<b>", as.character(.y), "</b>"),
                         rep("&nbsp;", 20),
                         rep("\n&nbsp;", 3)),
                       collapse = ""))) %>%
      layout(barmode = 'stack')
  }
  ) %>%
  subplot(nrows = NROW(.), margin = .05, shareX = T, shareY = T, titleY = T) 

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

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

はじめの一歩

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

調査の方向性

まず、plot_ly()、group_map()、subplot()を使用して、提供されている2つのR再現コードを実行し、離散色の場合と連続色の場合を比較します。subplotがトレースと凡例をどのように結合するかを追跡します。連続変数の凡例が、ファセットされたプロットの動作を損なわずに結合されれば完了です。

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

評価

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

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

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