scale_brewer {ggplot2}R Documentation

scale_brewer

Description

Sequential, diverging and qualitative colour scales from colorbrewer.org

Usage

scale_colour_brewer(name=NULL, palette=1, type="qual", limits=NULL, breaks=NULL, labels=NULL, formatter=identity, legend=TRUE, ...)
scale_fill_brewer(name=NULL, palette=1, type="qual", limits=NULL, breaks=NULL, labels=NULL, formatter=identity, legend=TRUE, ...)

Arguments

name name of scale to appear in legend or on axis. Maybe be an expression: see ?plotmath
palette Either numeric or character. If numeric, selects the nth palette of type type. If character, selects the named palette. Get a complete list of all parameters by running RColorBrewer::display.brewer.all(n=8, exact.n=FALSE)
type Type of scale. One of 'div' (diverging), 'qual' (qualitative, the default), 'seq' (sequential), or 'all' (all). Only used when palette is numeric.
limits numeric vector of length 2, giving the extent of the scale
breaks numeric vector indicating where breaks should lie
labels character vector giving labels associated with breaks
formatter NULL
legend NULL
... other arguments

Details

See <a href='http://colorbrewer.org'>colorbrewer.org</a> for more info

This page describes scale_brewer, see layer and qplot for how to create a complete plot from individual components.

Value

A layer

Author(s)

Hadley Wickham, http://had.co.nz/

See Also

Examples

## Not run: 
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
(d <- qplot(carat, price, data=dsamp, colour=clarity))

# Change scale label
d + scale_colour_brewer()
d + scale_colour_brewer("clarity")
d + scale_colour_brewer(expression(clarity[beta]))

# Select brewer palette to use, see ?brewer.pal for more details
d + scale_colour_brewer(type="seq")
d + scale_colour_brewer(type="seq", palette=3)

RColorBrewer::display.brewer.all(n=8, exact.n=FALSE)

d + scale_colour_brewer(palette="Blues")
d + scale_colour_brewer(palette="Set1")

# scale_fill_brewer works just the same as 
# scale_colour_brewer but for fill colours
ggplot(diamonds, aes(x=price, fill=cut)) + 
  geom_histogram(position="dodge", binwidth=1000) + 
  scale_fill_brewer()

## End(Not run)

[Package ggplot2 version 0.8.5 Index]