YonghuiDong/RawHummus

Split facet plot into a list of subplots

Closed this issue · 0 comments

When there are too many files (> 8), the facet plot is too compact and it becomes unclear for the users to inspect the figure. So it is better to split it into a list of subplots when the files are > 8.

When nfile <= 8, facet = 8;

When nfile > 8 and ceiling(file/2) < 8, facet = ceiling(file/2)

When nfile > 8 and ceiling(file/2) >= 8, facet = 8

To split the plot, I can use following code:

df <- data.frame(x=seq(1,24,1), y=seq(1,24,1), z=rep(seq(1,12),each=2))
library(tidyverse)
myplots3 <-
  df %>% 
  split(ceiling(group_indices(.,z)/n_facets)) %>% 
  map(~ggplot(.,aes(x =x, y=y))+geom_point()+facet_wrap(~z))

myplots3[[3]]