cowplot (version 0.7.0)

align_plots: Align multiple plots vertically and/or horizontally

Description

Align multiple plots for plotting manually. Can be used to graph two separate y axis, but still doesn't work if second y axis needs to be shown.

Usage

align_plots(..., plotlist = NULL, align = c("none", "h", "v", "hv"))

Arguments

...

List of plots to be aligned.

plotlist

(optional) List of plots to display. Alternatively, the plots can be provided individually as the first n arguments of the function plot_grid (see examples).

align

(optional) Specifies whether graphs in the grid should be horizontally ("h") or vertically ("v") aligned. Options are "none" (default), "hv" (align in both directions), "h", and "v".

Examples

Run this code
# NOT RUN {
p1 <- qplot(1:10, rpois(10, lambda=15), geom="point")
p2 <- qplot(1:10, (1:10)^2, geom="line") + theme_nothing()
# manually align and plot on top of each other
aligned_plots <- align_plots(p1, p2, align="hv")
ggdraw() + draw_grob(aligned_plots[[1]]) + draw_grob(aligned_plots[[2]])
# }

Run the code above in your browser using DataCamp Workspace