Color scales using the HDX palette. For discrete color scales, the
scale_color_hdx_...() and scale_fill_hdx_...() family of functions are
available. For gradient scales, use scale_color_gradient_hdx() and
scale_fill_gradient_hdx() functions for a single color scale or
scale_..._gradient2...() alternative.
scale_color_hdx_discrete(na.value = hdx_hex("gray-light"), ...)scale_colour_hdx_discrete(na.value = hdx_hex("gray-light"), ...)
scale_color_hdx_gray(na.value = hdx_hex("tomato-hdx"), ...)
scale_colour_hdx_gray(na.value = hdx_hex("tomato-hdx"), ...)
scale_colour_hdx_grey(na.value = hdx_hex("tomato-hdx"), ...)
scale_color_hdx_grey(na.value = hdx_hex("tomato-hdx"), ...)
scale_color_hdx_mint(na.value = hdx_hex("gray-light"), ...)
scale_colour_hdx_mint(na.value = hdx_hex("gray-light"), ...)
scale_color_hdx_sapphire(na.value = hdx_hex("gray-light"), ...)
scale_colour_hdx_sapphire(na.value = hdx_hex("gray-light"), ...)
scale_color_hdx_tomato(na.value = hdx_hex("gray-light"), ...)
scale_colour_hdx_tomato(na.value = hdx_hex("gray-light"), ...)
scale_fill_hdx_discrete(na.value = hdx_hex("gray-light"), ...)
scale_fill_hdx_gray(na.value = hdx_hex("tomato-hdx"), ...)
scale_fill_hdx_grey(na.value = hdx_hex("tomato-hdx"), ...)
scale_fill_hdx_mint(na.value = hdx_hex("gray-light"), ...)
scale_fill_hdx_sapphire(na.value = hdx_hex("gray-light"), ...)
scale_fill_hdx_tomato(na.value = hdx_hex("gray-light"), ...)
scale_fill_gradient_hdx(na.value = "transparent", ...)
scale_fill_gradient_hdx_sapphire(na.value = "transparent", ...)
scale_fill_gradient_hdx_mint(na.value = "transparent", ...)
scale_fill_gradient_hdx_tomato(na.value = "transparent", ...)
scale_color_gradient_hdx(na.value = "transparent", ...)
scale_colour_gradient_hdx(na.value = "transparent", ...)
scale_color_gradient_hdx_sapphire(na.value = "transparent", ...)
scale_colour_gradient_hdx_sapphire(na.value = "transparent", ...)
scale_color_gradient_hdx_mint(na.value = "transparent", ...)
scale_colour_gradient_hdx_mint(na.value = "transparent", ...)
scale_color_gradient_hdx_tomato(na.value = "transparent", ...)
scale_colour_gradient_hdx_tomato(na.value = "transparent", ...)
scale_color_gradient2_hdx(na.value = "transparent", ...)
scale_colour_gradient2_hdx(na.value = "transparent", ...)
scale_fill_gradient2_hdx(na.value = "transparent", ...)
Relevant ggplot2 scale object to add to a ggplot2::ggplot() plot,
either ggplot2::ScaleDiscrete or ggplot2::ScaleContinuous.
Colour to use for missing values
Arguments passed on to discrete_scale
paletteA palette function that when called with a single integer
argument (the number of levels in the scale) returns the values that
they should take (e.g., scales::pal_hue()).
breaksOne of:
NULL for no breaks
waiver() for the default breaks (the scale limits)
A character vector of breaks
A function that takes the limits as input and returns breaks as output. Also accepts rlang lambda function notation.
limitsOne of:
NULL to use the default scale values
A character vector that defines possible values of the scale and their order
A function that accepts the existing (automatic) values and returns new ones. Also accepts rlang lambda function notation.
dropShould unused factor levels be omitted from the scale?
The default, TRUE, uses the levels that appear in the data;
FALSE includes the levels in the factor. Please note that to display
every level in a legend, the layer should use show.legend = TRUE.
na.translateUnlike 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.
labelsOne 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)
An expression vector (must be the same length as breaks). See ?plotmath for details.
A function that takes the breaks as input and returns labels as output. Also accepts rlang lambda function notation.
guideA function used to create a guide or its name. See
guides() for more information.
callThe call used to construct the scale for reporting messages.
superThe super class to use for the constructed scale
gghdx() for setting default fill and color scaling,
along with other styling.
library(ggplot2)
# discrete scaling
p1 <- ggplot(iris) +
geom_point(
aes(
x = Sepal.Length,
y = Petal.Width,
color = Species
)
)
p1
p1 + scale_color_hdx_discrete()
p1 + scale_color_hdx_mint()
# use gradient scaling
p2 <- ggplot(iris) +
geom_point(
aes(
x = Sepal.Length,
y = Petal.Width,
color = Petal.Length
)
)
p2
p2 + scale_color_gradient_hdx_mint()
p2 + scale_color_gradient_hdx_tomato()
Run the code above in your browser using DataLab