I'm looking to plot a filled contour with geom_tile and the corresponding raw trace directly below it with no space between the two. When using gridExtra or cowplot, I can get them close but not to where the top of raw trace is on the x axis of the filled contour. Here are the details:
Data
library(reshape2)
library(ggplot2)
volcano=volcano
volcano3d=melt(volcano)
names(volcano3d) <- c("x", "y", "z")
Plots
fill=ggplot(volcano3d,aes(x,y,z))+geom_tile(aes(fill=z))
raw=ggplot(volcano3d,aes(x,y))+geom_line()+theme(aspect.ratio=1/20)
My attempts
library(gridExtra)
grid.arrange(fill,raw,heights=c(5,1)
While they are pretty close, I'd like to do a few things:
- Move the bottom trace up so the top of the bottom trace is touching the xaxis of the contour plot.
- Align the two axis so 0,25,50,75 are all aligned. In cowplot you can use the align the argument so that's fine, but I can't figure out how to move them closer to each other.
Ideal Plot
This is from a different data set, but its a good example of the layout.
thoughts?