View source: R/gnomer-color-palette.R
set_gnomer_palette | R Documentation |
This function sets the gnomeR color palette as the default palette for all
ggplot2 objects. It does so by overriding the following four functions from
the ggplot2 package: scale_color_discrete()
,
scale_fill_discrete()
, scale_color_continuous()
, and
scale_fill_continuous()
, and places them in the specified environment.
A typical workflow would include this function at the top of a script,
and subsequent calls to ggplot()
will utilize the gnomeR color palette.
set_gnomer_palette(
palette = c("pancan", "main", "sunset"),
gradient = c("pancan", "main", "sunset"),
reverse = FALSE,
env = rlang::caller_env()
)
palette |
name of palette in gnomer_palettes, supplied in quotes.
Options include |
gradient |
name of gradient palette in |
reverse |
if set to |
env |
environment in which palette will take effect. Default is |
Michael Curry
library(ggplot2)
set_gnomer_palette()
ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
geom_point()
# setting other gnomeR palettes
set_gnomer_palette(palette = "main", gradient = "sunset")
ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
geom_point()
ggplot(mtcars, aes(wt, mpg, color = cyl)) +
geom_point()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.