library(grid)
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp))
p2 <- ggplot(mtcars) +
geom_boxplot(aes(gear, disp, group = gear))
p1 + inset(p2, vp = viewport(0.6, 0.6,
just = c(0, 0), width = 0.4, height = 0.4
))
Run the code above in your browser using DataLab