scale_fill_jam: Apply rainbowJam categorical color fill to a ggplot2 object

scale_fill_jamR Documentation

Apply rainbowJam categorical color fill to a ggplot2 object

Description

Apply rainbowJam categorical color fill to a ggplot2 object

Usage

scale_fill_jam(
  ...,
  type = "seq",
  palette = 1,
  direction = 1,
  invert = FALSE,
  darkFactor = 1,
  sFactor = 1,
  darken = FALSE,
  alpha = 1,
  useGrey = 20,
  preset = getOption("colorjam.preset", "dichromat2"),
  step = getOption("colorjam.step", "default")
)

Arguments

...

additional arguments are passed to ggplot2::discrete_scale().

type

character string indicating the colors are sequential "seq", and is passed to colorjam::jam_pal().

palette

integer value indicating the categorical palette to use, intended to provide variety in the color assignment. (Not yet implemented.)

direction

integer indicating whether to reverse the color assignment, either 1 for the default forward assignment, or -1 for reverse assignment. Any negative value will reverse the colors.

invert

logical indicating whether to return corresponding contrasting colors, for example for text labels, typically either "white" or "black" as defined by jamba::setTextContrastColor().

darkFactor, sFactor

numeric passed to jamba::makeColorDarker() for optional adjustment of the color, by darkness and saturation, respectively. Intended when using scale_color_jam() and scale_fill_jam() where you want the color value to be lighter or darker than the fill color, a useful effect for outlines.

darken

logical indicating whether to apply default values for darkFactor and sFactor to darken the resulting colors.

alpha

numeric value indicating the alpha transparency, on a scale of 0 (transparent) to 1 (non-transparent).

useGrey

integer value between 0 and 100 indicating the grey value, as sent to jamba::setTextContrastColor(), used only when invert=TRUE.

Details

This function provides a function in the format ⁠scale_fill_*⁠ to be applied to ggplot2 objects. It can provide a more visibly distinct set of categorical colors than ggplot2::scale_fill_hue().

See Also

Other colorjam ggplot2: jam_pal(), scale_color_jam(), theme_jam()

Examples

if (jamba::check_pkg_installed("ggplot2")) {
   dsamp <- ggplot2::diamonds[sample(nrow(ggplot2::diamonds), 1000),];
   d <- ggplot2::ggplot(dsamp,
      ggplot2::aes(carat, price)) +
      ggplot2::geom_point(
         ggplot2::aes(colour=cut, bg=cut),
         pch=21,
         size=4);

   print(d +
      scale_color_jam(darkFactor=1.5) +
      scale_fill_jam() +
      ggplot2::ggtitle("scale_color_jam(darkFactor=1.5) + scale_fill_jam()"));

   print(d +
      scale_color_jam(darken=TRUE) +
      scale_fill_jam() +
      ggplot2::ggtitle("scale_color_jam(darkFactor=1.5) + scale_fill_jam()"));
}


jmw86069/colorjam documentation built on Dec. 16, 2024, 8:02 a.m.