Description Usage Arguments Examples
The scale_color_dgi
and scale_fill_dgi
functions provide various palettes with DGI Clinical brand colors for use with ggplot2
.
1 2 3 | scale_color_dgi(palette = "main", type = "discrete", reverse = FALSE, ...)
scale_fill_dgi(palette = "main", type = "discrete", reverse = FALSE, ...)
|
palette |
Character name of palette: "main" (default), "cool", "grey", "mixed", "teal white", "teal black", "teal grey", "blue white", "blue black", "blue grey", "sea green white", "sea green black", "sea green grey", "complementary", "split-complementary", "triadic", "tetradic", or "qualitative". |
type |
Type of data, "discrete" (default) or "continuous". If "discrete", and the number of levels > number of colors, then additional colors will be generated by interpolation with |
reverse |
Boolean to reverse palette order, default FALSE. |
... |
Arguments passed on to
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | library(ggplot2)
library(dplyr)
# The default palette for scale_color_dgi() is "main", which returns the
# three primary DGI colors
ggplot(mtcars, aes(hp, mpg, color = factor(cyl))) +
geom_point(size = 4) +
scale_color_dgi() +
theme_minimal()
# In this case, there are five Month values, so two additional colors are
# automatically interpolated
ggplot(airquality, aes(x = Day, y = Temp,
group = as.factor(Month), color = as.factor(Month))) +
geom_point(size = 2.5) +
scale_color_dgi() +
theme_minimal()
ggplot(airquality, aes(x = Day, y = Temp,
group = as.factor(Month), color = Month)) +
geom_point(size = 2.5) +
scale_color_dgi(type = "continuous") +
theme_minimal()
# Generate some three-dimensional data
df <- data.frame(
x = runif(100),
y = runif(100),
z = rnorm(100)
)
ggplot(df, aes(x, y)) +
geom_point(aes(color = z), size = 4) +
scale_color_dgi(type = "continuous", reverse = TRUE) +
theme_minimal()
# A number of color palettes, using teal as the base, are also available
# Two-color complementary
ggplot(mtcars, aes(x = factor(am), y = disp, fill = factor(am))) +
geom_boxplot() +
scale_fill_dgi("complementary")
# Three-color split-complementary
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
geom_point(size = 4) +
scale_color_dgi("split-complementary")
# Triadic
ggplot(iris, aes(x = Sepal.Width, y = Sepal.Length, color = Species)) +
geom_point(size = 4) +
scale_color_dgi("triadic")
# Tetradic
data.frame(Titanic) %>%
group_by(Class, Survived) %>%
summarise(n = sum(Freq)) %>%
ggplot(aes(Survived, n, fill = Class)) +
geom_col(position = "dodge") +
scale_fill_dgi("tetradic")
# A five color qualitative scale
diamonds %>%
group_by(cut) %>%
sample_n(100) %>%
ggplot(aes(carat, price, color = cut)) +
geom_point(size = 3) +
scale_color_dgi("qualitative")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.