suppressPackageStartupMessages({
library(tidyverse)
library(cowplot)
library(patchwork)
theme_set(theme_cowplot())
})
options(repr.plot.width=16,repr.plot.height=10)
Composing multiple plots in a single page#
p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) + ggtitle('Plot 1')
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear)) + ggtitle('Plot 2')
Inset plots and tables#
library(ggpp)
p <- ggplot(mpg, aes(factor(cyl), hwy)) +
stat_summary(geom = "col", fun = mean, width = 2/3)
ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
annotate("plot", x = 7, y = 44, label = p) +
geom_point(size=3)
Plot zoom#
library(ggforce)