Construct ggplot2 scale with KU color palette
scale_fill_ku(palette = "full", discrete = TRUE, reverse = FALSE, ...)
character. one of the names in ku_palettes
boolean. FALSE
implies a continuous
palette.
boolean. whether to reverse the order
additional arguments passed to
discrete_scale()
or scale_color_gradientn()
when
discrete
is TRUE
or FALSE
, respectively.
ggplot2 scale
if (base::interactive()) {
library(dplyr)
library(ggplot2)
library(magrittr)
mtcars %>%
dplyr::mutate(cyl = base::factor(cyl, levels = c("4", "6", "8"), ordered = TRUE)) %>%
ggplot2::ggplot() +
ggplot2::aes(x = wt, fill = cyl) +
ggplot2::geom_histogram(bins = 6) +
scale_fill_ku("cat3_ext", name = "Number of cylinders") +
ggplot2::scale_y_continuous(breaks = base::seq.int(0L, 12L, by = 2L)) +
ggplot2::xlab("Mass / 1000 lb") +
ggplot2::ylab("Frequency") +
ggplot2::ggtitle(
label = "Fuel efficiency versus mass and number of cylinders",
subtitle = "Example of scale_fill_ku()"
) +
ggplot2::theme_minimal() +
ggplot2::theme(
plot.title = ggtext::element_markdown(lineheight = 1.1),
plot.subtitle = ggtext::element_markdown(lineheight = 1.1)
)
}
# scale_fill_ku <- paletti::get_scale_fill(paletti::get_pal(ku_palettes))