View source: R/grid_arrange_shared_legend.R
grid_arrange_shared_legend | R Documentation |
Share a legend between ggplot2 graphs
grid_arrange_shared_legend(..., ncol = 1)
... |
ggplot plots, |
ncol |
A number of columns for plots in the plot. |
grop and should be plot with grid.draw
Shaun Jackman and Janne Huovari
https://github.com/hadley/ggplot2/wiki/Share-a-legend-between-two-ggplot2-graphs
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.