# A standard plot
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point()
# The `design` argument can be a character string.
# New rows are indicated by newline symbol (`\n`), which are added
# automatically for multi-line strings.
# The `#`-symbol indicates empty cells.
design <- "
A##
AB#
#BC
##C
"
p + facet_manual(~ cyl, design)
# Alternatively, the `design` argument can be a matrix.
# Using `NA`s will leave the cell empty.
design <- matrix(c(1,2,3,3), 2, 2, byrow = TRUE)
p + facet_manual(~ cyl, design)
# The sizes of columns and rows can be adjusted with the `widths` and
# `heights`parameters respectively.
p + facet_manual(
~ cyl, t(design),
widths = c(2, 1), heights = c(2, 1), respect = TRUE
)
Run the code above in your browser using DataLab