Unequal facet heights
オープン
まだ誰も着手していません。
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
In the reprex below, the first and last panels are noticeably taller than the others (note the y axis ticks are overlapping for the remaining panels).
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
library(plyr)
#>
#> Attaching package: 'plyr'
#> The following objects are masked from 'package:plotly':
#>
#> arrange, mutate, rename, summarise
date <- rep(as.Date(1:365,origin='2011-1-1'),7)
location <- factor(rep(1:7,365))
product <- rep(letters[1:7], each=365)
value <- c(sample(1:10, size=365, replace=T),
sample(1:3, size=365, replace=T),
sample(10:100, size=365, replace=T),
sample(1:50, size=365, replace=T),
sample(1:20, size=365, replace=T),
sample(50:100, size=365, replace=T),
sample(1:100, size=365, replace=T))
dat<-data.frame(date,location,product,value)
p <- ggplot(dat, aes(x=date, y=value, color=location, group=location)) +
geom_line()+
theme(panel.spacing.y = ggplot2::unit(1, "lines")) +
facet_grid(product ~ ., scales = "fixed")
ggplotly(p)

(Also, the legend compresses the first few panels awkwardly, but that is a separate issue).
The problem also occurs with facet_wrap():
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
library(plyr)
#>
#> Attaching package: 'plyr'
#> The following objects are masked from 'package:plotly':
#>
#> arrange, mutate, rename, summarise
date <- rep(as.Date(1:365,origin='2011-1-1'),7)
location <- factor(rep(1:7,365))
product <- rep(letters[1:7], each=365)
value <- c(sample(1:10, size=365, replace=T),
sample(1:3, size=365, replace=T),
sample(10:100, size=365, replace=T),
sample(1:50, size=365, replace=T),
sample(1:20, size=365, replace=T),
sample(50:100, size=365, replace=T),
sample(1:100, size=365, replace=T))
dat<-data.frame(date,location,product,value)
p <- ggplot(dat, aes(x=date, y=value, color=location, group=location)) +
geom_line()+
theme(panel.spacing.y = ggplot2::unit(1, "lines")) +
facet_wrap(ncol = 1, vars(product), scales = "fixed")
ggplotly(p)

This issue doesn't appear to be coming from ggplot, but rather from ggplotly:
library(plotly)
#> Loading required package: ggplot2
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
library(plyr)
#>
#> Attaching package: 'plyr'
#> The following objects are masked from 'package:plotly':
#>
#> arrange, mutate, rename, summarise
date <- rep(as.Date(1:365,origin='2011-1-1'),7)
location <- factor(rep(1:7,365))
product <- rep(letters[1:7], each=365)
value <- c(sample(1:10, size=365, replace=T),
sample(1:3, size=365, replace=T),
sample(10:100, size=365, replace=T),
sample(1:50, size=365, replace=T),
sample(1:20, size=365, replace=T),
sample(50:100, size=365, replace=T),
sample(1:100, size=365, replace=T))
dat<-data.frame(date,location,product,value)
p <- ggplot(dat, aes(x=date, y=value, color=location, group=location)) +
geom_line()+
theme(panel.spacing.y = ggplot2::unit(1, "lines")) +
facet_grid(product ~., scales = "fixed")
print(p)

Created on 2022-01-12 by the reprex package (v2.0.1)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された R reprex を ggplotly() で実行し、facet_grid() と facet_wrap() の出力を、適切なサイズの ggplot の結果と比較します。ggplotly による facet レイアウトの変換を追跡し、パネルの高さまたは間隔が不均等になる箇所を特定します。両方の例で、高さが等しいパネルが y 軸の目盛りと重ならずに描画されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- plotly, r
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100