scale_color_dgi: DGI Clinical color and fill scales

Description Usage Arguments Examples

View source: R/dgi_palette.R

Description

The scale_color_dgi and scale_fill_dgi functions provide various palettes with DGI Clinical brand colors for use with ggplot2.

Usage

1
2
3
scale_color_dgi(palette = "main", type = "discrete", reverse = FALSE, ...)

scale_fill_dgi(palette = "main", type = "discrete", reverse = FALSE, ...)

Arguments

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 grDevices::colorRampPalette().

reverse

Boolean to reverse palette order, default FALSE.

...

Arguments passed on to ggplot2::discrete_scale

aesthetics

The names of the aesthetics that this scale works with

scale_name

The name of the scale

name

The name of the scale. Used as the axis or legend title. If waiver(), the default, the name of the scale is taken from the first mapping used for that aesthetic. If NULL, the legend title will be omitted.

breaks

One of:

  • NULL for no breaks

  • waiver() for the default breaks computed by the transformation object

  • A character vector of breaks

  • A function that takes the limits as input and returns breaks as output

labels

One of:

  • NULL for no labels

  • waiver() for the default labels computed by the transformation object

  • A character vector giving labels (must be same length as breaks)

  • A function that takes the breaks as input and returns labels as output

limits

A character vector that defines possible values of the scale and their order.

expand

Vector of range expansion constants used to add some padding around the data, to ensure that they are placed some distance away from the axes. Use the convenience function expand_scale() to generate the values for the expand argument. The defaults are to expand the scale by 5% on each side for continuous variables, and by 0.6 units on each side for discrete variables.

na.translate

Unlike continuous scales, discrete scales can easily show missing values, and do so by default. If you want to remove missing values from a discrete scale, specify na.translate = FALSE.

na.value

If na.translate = TRUE, what value aesthetic value should missing be displayed as? Does not apply to position scales where NA is always placed at the far right.

drop

Should unused factor levels be omitted from the scale? The default, TRUE, uses the levels that appear in the data; FALSE uses all the levels in the factor.

guide

A function used to create a guide or its name. See guides() for more info.

position

The position of the axis. "left" or "right" for vertical scales, "top" or "bottom" for horizontal scales

super

The super class to use for the constructed scale

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
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")

taylordunn/dgitheme documentation built on March 10, 2020, 5:01 p.m.