guide_legends {ggplot2}R Documentation

Build all legend grob

Description

Build legends, merging where possible

Usage

guide_legends(scales, layers, default_mapping, theme)

Arguments

scales
layers
default_mapping
theme

Value

A list of grobs

Author(s)

Hadley Wickham <h.wickham@gmail.com>

Examples

theme_update(legend.background = theme_rect(size = 0.2))
qplot(mpg, wt, data = mtcars)
qplot(mpg, wt, data = mtcars, colour = cyl)

# Legend with should expand to fit name
qplot(mpg, wt, data = mtcars, colour = factor(cyl))

qplot(mpg, wt, data = mtcars, colour = cyl) +
opts(legend.position = c(0.5, 0.5), 
legend.background = theme_rect(fill = "white", col = NA))

mtcars$cyl2 <- factor(mtcars$cyl, 
labels = c("a", "loooooooooooong", "two\nlines"))
qplot(mpg, wt, data = mtcars, colour = cyl2)
theme_set(theme_grey())

[Package ggplot2 version 0.8.2 Index]