Top and Bottom plots seem to have less spacing when using `subplot` in `plotly`
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza ejecutando el reprex de R proporcionado con subplot y 45 histogramas para reproducir el problema de espaciado entre las filas superior e inferior. Rastrea el comportamiento del diseño de subplot y verifica que los histogramas resultantes tengan márgenes iguales con etiquetas visibles; el problema se resuelve cuando los gráficos superiores e inferiores tienen un espaciado uniforme.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100