scale_manual {ggplot2}R Documentation

scale\_manual

Description

Create your own discrete scale

Usage

scale_colour_manual(name = NULL, values = NULL, 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

values

NULL

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

...

ignored

Details

This page describes scale\_manual, 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: 
p <- qplot(mpg, wt, data = mtcars, colour = factor(cyl))

p + scale_colour_manual(values = c("red","blue", "green"))
p + scale_colour_manual(
  values = c("8" = "red","4" = "blue","6" = "green"))

# As with other scales you can use breaks to control the appearance
# of the legend
cols <- c("8" = "red","4" = "blue","6" = "darkgreen", "10" = "orange")
p + scale_colour_manual(values = cols)
p + scale_colour_manual(values = cols, breaks = c("4", "6", "8"))
p + scale_colour_manual(values = cols, breaks = c("8", "6", "4"))
p + scale_colour_manual(values = cols, breaks = c("4", "6", "8"),
  labels = c("four", "six", "eight"))

# And limits to control the possible values of the scale
p + scale_colour_manual(values = cols, limits = c("4", "8"))
p + scale_colour_manual(values = cols, limits = c("4", "6", "8", "10"))


## End(Not run)

[Package ggplot2 version 0.8.9 Index]