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", 
    na.colour = "grey80", 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.

na.colour

colour to use for missing values

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.9 Index]