scale_manual {ggplot2} | R Documentation |
Create your own discrete scale
scale_colour_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, legend=TRUE, ...) scale_fill_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, legend=TRUE, ...) scale_size_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, legend=TRUE, ...) scale_shape_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, legend=TRUE, ...) scale_linetype_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, legend=TRUE, ...)
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 |
This page describes scale_manual, see layer
and qplot
for how to create a complete plot from individual components.
A layer
Hadley Wickham, http://had.co.nz/
## 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)