Solution to combine facetted legends breaks for continuous variable
オープン
まだ誰も着手していません。
- 主要言語
- 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(" ", 20),
paste("<b>", as.character(.y), "</b>"),
rep(" ", 20),
rep("\n ", 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(" ", 20),
paste("<b>", as.character(.y), "</b>"),
rep(" ", 20),
rep("\n ", 3)),
collapse = ""))) %>%
layout(barmode = 'stack')
}
) %>%
subplot(nrows = NROW(.), margin = .05, shareX = T, shareY = T, titleY = T)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、plot_ly()、group_map()、subplot()を使用して、提供されている2つのR再現コードを実行し、離散色の場合と連続色の場合を比較します。subplotがトレースと凡例をどのように結合するかを追跡します。連続変数の凡例が、ファセットされたプロットの動作を損なわずに結合されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- r
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100