You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 datasetsimulateDataset<-function(numRows=100, numCols=40) {
data<-data.frame(matrix(nrow=numRows, ncol=numCols))
for (iin1: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 datadf<- simulateDataset(numRows=100, numCols=60)
# create histograms and convert to plotlyplotList<- 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 rownumberOfRows<- 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
The text was updated successfully, but these errors were encountered:
Description:
When attempting to display multiple histograms using
subplot
from theplotly
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:
Expected Behavior:
Each histogram should be clearly separated from the others, with appropriate spacing and labels visible.
Screenshot
The text was updated successfully, but these errors were encountered: