title: How can I squish two halves of two separate correlation heatmaps together?
body: <p>I have two sets of data for the same set of variables and I can make a correlation heatmap of each of them quite easily. However, I would like to squish the two halves of the two separate correlation heatmaps together. If you run the code below, you'll generate two separate heatmaps that could theoretically be aligned on the 1:1 line and have the top panel be correlations from df1, and the bottom panel be correlations from df2. Is there some way to cause overlapping of two figures with grid package functions or otherwise? Or will I have to bring this into GIMP or something and arrange them?</p>
  
  <pre><code>library(tidyverse)
  library(gridExtra)
  library(reshape2)
  
  get_upper_tri &lt;- function(cormat){
      cormat[lower.tri(cormat)]&lt;- NA
      return(cormat)
  }
  
  get_lower_tri &lt;- function(cormat){
      cormat[upper.tri(cormat)]&lt;- NA
      return(cormat)
  }
  
  df1 &lt;- data.frame(a = rnorm(100, 10),
                    b = rnorm(100, 50),
                    c = rnorm(100, 12),
                    d = rnorm(100, 35))
  
  cor1 &lt;- cor(df1)
  
  cor1 &lt;- get_upper_tri(cor1)
  
  p1 &lt;- melt(cor1) %&gt;%
    filter(is.na(value) == FALSE &amp; value != 1) %&gt;%
    ggplot(., aes(Var1, Var2, fill = value))+
    geom_raster()+
    scale_fill_viridis_c(guide = FALSE)+
    theme(panel.background = element_blank(),
          axis.ticks = element_blank())+
    labs(x = NULL, y = NULL)
  
  df2 &lt;- data.frame(a = rnorm(100, 65),
                    b = rnorm(100, 1),
                    c = rnorm(100, 1000),
                    d = rnorm(100, 500))
  
  cor2 &lt;- cor(df2)
  
  cor2 &lt;- get_lower_tri(cor2)
  
  p1 &lt;- melt(cor1) %&gt;%
    filter(is.na(value) == FALSE) %&gt;%
    ggplot(., aes(Var1, Var2, fill = value))+
    geom_raster()+
    scale_fill_viridis_c(guide = FALSE)+
    theme(panel.background = element_blank(),
          axis.ticks = element_blank())+
    labs(x = NULL, y = NULL)+
    geom_text(aes(label = round(value, 2)))
  
  p2 &lt;- melt(cor2) %&gt;%
    filter(is.na(value) == FALSE) %&gt;%
    ggplot(., aes(Var1, Var2, fill = value))+
    geom_raster()+
    scale_fill_viridis_c(guide = FALSE)+
    theme(panel.background = element_blank(),
          axis.ticks = element_blank())+
    labs(x = NULL, y = NULL)+
    geom_text(aes(label = round(value, 2)))
  
  grid.arrange(p1, p2, ncol = 2)
  </code></pre>