scale_colour_palette_d {palettes} | R Documentation |
Colour scales from colour vectors and colour palettes
Description
Create discrete, continuous, and binned colour scales from colour vectors and colour palettes.
Usage
scale_colour_palette_d(palette, direction = 1, ...)
scale_fill_palette_d(palette, direction = 1, ...)
scale_colour_palette_c(palette, direction = 1, ...)
scale_fill_palette_c(palette, direction = 1, ...)
scale_colour_palette_b(palette, direction = 1, ...)
scale_fill_palette_b(palette, direction = 1, ...)
Arguments
palette |
An object of class |
direction |
Sets the order of colours in the scale. If 1, the default, colours are ordered from first to last. If -1, the order of colours is reversed. |
... |
Other arguments passed on to |
Value
A scale function that controls the mapping between data and colour or fill aesthetics in a ggplot2 plot.
Examples
library(ggplot2)
# Use palette_d with discrete data
discrete_pal <- pal_colour(c("#663171", "#EA7428", "#0C7156"))
ggplot(mtcars, aes(wt, mpg, colour = as.factor(cyl))) +
geom_point(size = 3) +
scale_colour_palette_d(discrete_pal)
# Use palette_c with continuous data
continuous_pal <- pal_colour(c("#3C0D03", "#E67424", "#F5C34D"))
ggplot(mtcars, aes(wt, mpg, colour = mpg)) +
geom_point(size = 3) +
scale_colour_palette_c(continuous_pal)
# Use palette_b to bin continuous data before mapping
ggplot(mtcars, aes(wt, mpg, colour = mpg)) +
geom_point(size = 3) +
scale_colour_palette_b(continuous_pal)
[Package palettes version 0.2.1 Index]