scale_manual

scale_colour_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, ...)
scale_fill_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, ...)
scale_size_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, ...)
scale_shape_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, ...)
scale_linetype_manual(name=NULL, values=NULL, limits=NULL, breaks=NULL, labels=NULL, formatter=identity, ...)

Create your own discrete scale

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

What do you think of the documentation? Please let me know by filling out this short online survey.

Parameters

Parameters control the appearance of the scale. In addition to the parameters listed below (if any), any aesthetic can be used as a parameter, in which case it will override any aesthetic mapping.

Returns

This function returns a scale object.

Examples

> 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")) 
  

What do you think of the documentation? Please let me know by filling out this short online survey.