View source: R/gnomer-color-palette.R
gnomer_palette | R Documentation |
gnomeR colors can be accessed and used in plotting
gnomer_palette(
name = "pancan",
n,
type = c("discrete", "continuous"),
plot_col = FALSE,
reverse = FALSE,
...
)
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. |
plot_col |
Boolean value weather to plot the palette labeled with their hex codes. Defalut is FALSE. |
reverse |
Boolean indicating whether the palette should be reversed. Default is FALSE. |
... |
Additional parameters to pass too |
A vector of colours.
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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.