2

I have 16 samples and want to graph individual histograms along with the median of the samples for each observation. I would like the emphasis to be on the median, so I wanted to make it the largest (say 4x) and fit the remaining facets around it, like a reverse inset. My ideal layout would be:

med med  a  b  c 
med med  d  e  f 
 g   h   i  j  k
 l   m   n  o  p

Here's some code to make sample faceted histograms:

library(ggplot2)

tibble(
    sample = factor(c("median", letters[1:16]), levels = c("median", letters[1:16])),
    data = list(c(.1,.1,.1,.2,.8,.9,.9,.9))
) %>% unnest %>% 
    ggplot(aes(x = data)) +
    geom_histogram() +
    facet_wrap(~ sample, ncol = 4, scales='free', shrink = TRUE) +
    scale_x_continuous(breaks = c(0,.5, 1.0)) 

I wondered if I could somehow work with scale or shrink but I'm not sure where to start with those. Perhaps I need to place filler data in the slots and then use grid to overlay a larger plot on top? In either case, I'm not sure how to begin and would appreciate any help.

GenesRus
  • 1,057
  • 6
  • 16
  • 1
    Maybe you can try [multipanelfigure package](https://stackoverflow.com/a/51220506/786542) – Tung Aug 13 '19 at 20:27

0 Answers0