Plots seem merged when using `subplot` in `plotly`
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Description:
When attempting to display multiple histograms using subplot from the plotly package, the plots appear merged together, making them difficult to distinguish. 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 = 60)
# 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') +
theme_minimal()
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 be clearly separated from the others, with appropriate spacing and labels visible.
Screenshot
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo il R reprex fornito con plotly::subplot e verifica come il layout di subplot gestisce margini, spaziatura ed etichette degli assi all’aumentare del numero di grafici. L’issue è completata quando gli istogrammi rimangono visivamente separati e le relative etichette sono leggibili nella grande disposizione con più grafici.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- plotly, r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100