gnomer_palette: Access the colors in a gnomeR color palette

Description Usage Arguments Value Examples

View source: R/gnomer_color_palette.R

Description

gnomeR colors can be accessed and used in plotting

Usage

1
gnomer_palette(name = "pancan", n, type = c("discrete", "continuous"))

Arguments

name

Name of desired palette, supplied in quotes. Choices are: "pancan" (default) (best for discrete), "main" (better for discrete), "sunset" (continuous)

n

Number of colors desired. If omitted, uses all colors, or the needed number of colors if less than the total.

type

Either "continuous" or "discrete". Use continuous if you want to automatically interpolate between colours. @importFrom graphics rgb rect par image text @importFrom grDevices colorRampPalette

Value

A vector of colours.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(ggplot2)

# Print a plot showing the colors in a palette, in order
gnomer_palette("pancan")

# use a single brand color from a palette
# here using the fourth color from the "pancan" palette
ggplot(mtcars, aes(hp, mpg)) +
geom_point(size = 4, color = gnomer_palette("pancan")[4])

# use a discrete color scale - uses fixed colors from the requested palette
ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
geom_point(size = 4) +
scale_color_manual(values = gnomer_palette("pancan"))

# use a continuous color scale - interpolates between colors
ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Sepal.Length)) +
geom_point(size = 4, alpha = .6) +
scale_color_gradientn(colors = gnomer_palette("sunset", type = "continuous"))

# use a fill color
ggplot(iris, aes(x = Sepal.Length, fill = Species)) +
geom_histogram(bins = 20, position = "dodge") +
scale_fill_manual(values = gnomer_palette("pancan"))

margarethannum/gnomeR documentation built on Feb. 26, 2020, 8:16 p.m.