Top and Bottom plots seem to have less spacing when using `subplot` in `plotly`
オープン
まだ誰も着手していません。
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Description:
When attempting to display multiple histograms using subplot from the plotly package, the plots in the top row and bottom row appear with less spacing, making them difficult to analyze. This issue is primarily reproducible when there are large number of visualizations to plot together.
Here is a minimal reprex for the same:
# Load necessary libraries
library(ggplot2)
library(plotly)
# set seed for reproducibility
set.seed(123)
# simulate a dataset
simulateDataset <- function(numRows = 100, numCols = 40) {
data <- data.frame(matrix(nrow = numRows, ncol = numCols))
for (i in 1:numCols) {
if (i %% 2 == 0) {
data[[i]] <- rnorm(numRows, mean = 50, sd = 10) # Normal distribution
} else {
data[[i]] <- rexp(numRows, rate = 0.1) # Exponential distribution
}
}
names(data) <- paste0("Var", 1:numCols)
return(data)
}
# simulate the data
df <- simulateDataset(numRows = 100, numCols = 45)
# create histograms and convert to plotly
plotList <- lapply(names(df), function(colName) {
if (is.numeric(df[[colName]])) {
p <- ggplot(df, aes(x = .data[[colName]])) +
geom_histogram(binwidth = 0.5, fill = 'grey', color = 'black')
ggplotly(p)
}
})
# define number of rows based on number of plots in each row
numberOfRows <- ceiling(length(plotList) / 3)
# display all plots together using subplot
subplot(plotList, nrows = numberOfRows, margin = 0.05, titleX = TRUE, titleY = TRUE)
Expected Behavior:
Each histogram should have equal margins, with appropriate spacing and labels visible.
Screenshots
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された subplot と 45 個のヒストグラムを含む R reprex を実行して、上段と下段の間隔の問題を再現します。subplot のレイアウト動作を追跡し、生成されたヒストグラムのマージンが等しく、ラベルが表示されていることを確認します。上段と下段のプロットが一貫して間隔を空けて配置されれば、問題は解決です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- r
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100