grid_arrange_shared_legend: Share a legend between ggplot2 graphs

View source: R/grid_arrange_shared_legend.R

grid_arrange_shared_legendR Documentation

Share a legend between ggplot2 graphs

Description

Share a legend between ggplot2 graphs

Usage

grid_arrange_shared_legend(..., ncol = 1)

Arguments

...

ggplot plots,

ncol

A number of columns for plots in the plot.

Value

grop and should be plot with grid.draw

Author(s)

Shaun Jackman and Janne Huovari

See Also

https://github.com/hadley/ggplot2/wiki/Share-a-legend-between-two-ggplot2-graphs

Examples

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
p1 <- qplot(carat, price, data=dsamp, colour=clarity)
p2 <- qplot(cut, price, data=dsamp, colour=clarity)
p3 <- qplot(color, price, data=dsamp, colour=clarity)
p4 <- qplot(depth, price, data=dsamp, colour=clarity)
grid_arrange_shared_legend(p1, p2, p3, p4, ncol = 2)

pttry/ggptt documentation built on May 4, 2023, 2:48 p.m.