This function aligns ggplots vertically or horizontally

ggAlignPlots(..., plotList = NULL, sizes = NULL, type = "v", draw = TRUE)

Arguments

...

All additional arguments will be interpreted as ggplot2 plot objects and used if and only if plotList is NULL

plotList

A list of ggplot2 plot objects to be aligned.

sizes

A numeric vector or list of values indicating the relative size for each of the objects in plotList or supplied in .... If the plot is supplied in ... the order is the same as the input in this function. If set to NULL all plots will be evenly distributed.

type

A string indicating wheter vertical ("v") or horizontal ("h") alignment should be used for the multi-plot layout.

draw

A boolean value indicating whether to draw the plot(s) (TRUE) or return a graphical object (FALSE).

Examples


# Create Random Data
m <- data.frame(x=matrix(rnorm(10, 2),ncol=1))
m$color <- sample(c("A", "B"), 10, replace = TRUE)

# Plot
p <- ggGroup(x = m$color, y = m$x)

# To PDF
pdf("test.pdf", width = 4, height = 7)
ggAlignPlots(p, p)
dev.off()