plotly / plotly/plotly.R

Panels are different sizes when converting ggplot plot with facets

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

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

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

説明


When converting a ggplot plot with facets to a plotly object the panels are different sizes. Margins are not subtracted from top and bottom rows so these panels end up being taller. This makes it hard to compare among panels. Margins for top and bottom of panels are equal so longer x-axis labels result in large margins on tops of panels with large spacing between panels and a low data-ink ratio.

library(dplyr)
library(ggplot2)
library(plotly)
library(reshape2)

p <- ggplot(data = tips,
            aes(x = sex, y = total_bill)) +
  geom_jitter(width = 0.1, height = 0) +
  facet_wrap(day ~ time, scales = "free_x", ncol = 2) +
  theme(axis.text.x = element_text(angle = 45),
        strip.text.x = element_text(size = 8, 
                                    margin = margin(t = 1, r = 0, b = 1, l = 0, unit = "pt")))

q <- ggplotly(p) %>% 
  plotly::layout(margin = list(l = 80, r = 0, t = 100, b = 100, pad = 0))

d <- rbind(q$x$layout$yaxis4$domain, q$x$layout$yaxis3$domain, q$x$layout$yaxis2$domain, q$x$layout$yaxis$domain)
df <- data_frame(lb = d[,1], ub = d[,2]) %>% 
  mutate(range = ub - lb,
         panelSpacing = lb - lag(ub))

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

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

はじめの一歩

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

調査の方向性

提供された ggplotly() の例で問題を再現し、d に収集された y 軸のドメイン値を調べてください。まず、facet パネルとレイアウトのマージンがどのように変換されるかを追跡し、次に上部パネルと下部パネルのサイズが等しく、間隔が設定されたマージンを反映していることを確認してください。

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

評価

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

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

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