R scale_colour_fermenter() Function

The scale_colour_fermenter() function is used to set the colors for a plot using a palette from the Fermenter package.

Syntax

scale_fill_fermenter(
  type = "seq",
  palette = 1,
  direction = -1,
  na.value = "grey50",
  guide = "coloursteps",
  aesthetics = "fill"
)

Parameters

  1. type: It is one of “seq” (sequential), “div” (diverging), or “qual” (qualitative)
  2. palette: If a string will use that named palette. If a number is indexed into the list of palettes of the appropriate type. The list of available palettes can be found in the Palettes section.
  3. direction: It sets the order of colors in the scale. If 1, the default colors are as output by RColorBrewer::brewer.pal(). If -1, the order of colors is reversed.
  4. aesthetics: The character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with.
  5. na.value: It is a color for missing values
  6. guide: Type of legend. Use “colourbar” for continuous color bar or “legend” for discrete color legend.

Example

library(ggplot2)

# Create a scatterplot of mpg vs. hp, with points colored 
# by the number of cylinders
p <- ggplot(mtcars, aes(x = hp, y = mpg, colour = cyl)) +
 geom_point()

# Adjust the color of the points using the 
# scale_colour_fermenter() function
p + scale_colour_fermenter(palette = 1, name = "Cylinders")

Output

Graphical representation of scale_colour_fermenter() Function in R

Related posts

scale_fill_fermenter()

Leave a Comment