r - ggplot, facets: specify number of panels -


i want plot data in ggplot facets in rnotebook. don't know beforehand how many facets there , want plots same size regardless of how many plots there are. say, whether plot 25 or 5 facets, each individual plot should same size in both cases.

one potential workaround use facet_wrap , try manipulate overall size of figure on fly (see here), doesn't appear option in rnotebook. so, plan b specify figure size in chunk , plot same size grid (e.g., 5x5) regardless of how many facets there are, populating of facets in grid. way plots same size regardless of how many facets there are, i'll have blanks spots can live with.

my first attempt using facet_wrap specifying ncol , nrow below.

# load library library(ggplot2)  # load data data(mtcars)  # plot data p <- ggplot(mtcars,aes(x = disp, y = mpg)) + geom_point() + facet_wrap( ~ + gear, ncol = 5, nrow = 5) print(p) 

this doesn't work , produces row of 4 figures instead of 5x5 grid 21 blank spots. facet_grid doesn't appear have option specify numbers of columns , rows, i'm not sure how i'd that. create plots in loop , store them in 25 element list, plotted plot_grid cowplot, seems quite cludgy. there more elegant solution?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -