1

I'm looking to achieve the following plot configuration with ggplot2 where the red area is the "main" graph of the plot and the blue area a completely different graph that I want to include in approximately the proportions showed. Both graphs are intended to be square shaped.

example

I know this is possible in base r, but no idea regarding whether or not this is feasible with ggplot. Is this even possible? if so, how can I get two blank graphs configured like this in a single plot?

MikeKatz45
  • 545
  • 5
  • 16

1 Answers1

3

Here is a gridExtra::grid.arrange approach. You set the layout_matrix argument as you want the plots to appear; use NA for blank space.

library(ggplot2)
library(gridExtra)

# We have two plots which are indexed 1 & 2
# the repeats of values give the space each plot will inhabit
lay = rbind(c(NA,NA,NA,1,1),
            c(NA,NA,NA,1,1),
            c(2,2,2,2,NA),
            c(2,2,2,2,NA),
            c(2,2,2,2,NA),
            c(2,2,2,2,NA))

grid.arrange(ggplot(), ggplot(), layout_matrix=lay)
user20650
  • 24,654
  • 5
  • 56
  • 91