Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

discrete_scale

Discrete scale constructor.


Description

Discrete scale constructor.

Usage

discrete_scale(
  aesthetics,
  scale_name,
  palette,
  name = waiver(),
  breaks = waiver(),
  labels = waiver(),
  limits = NULL,
  expand = waiver(),
  na.value = NA,
  drop = TRUE,
  guide = "legend"
)

Arguments

aesthetics

the names of the aesthetics that this scale works with

scale_name

the name of the scale

palette

a palette function that when called with a single integer argument (the number of levels in the scale) returns the values that they should take

name

the name of the scale - used as the axis label or the legend title

breaks

control the breaks in the guide. There are four possible types of input:

  • NULL: don't display any breaks

  • a character vector giving the breaks as they should appear on the axis or in the legend.

  • waiver() to use the default break computation.

  • a function, that when called with a single argument, a character vector giving the limits of the scale, returns a character vector specifying which breaks to display.

This parameter does not affect in any way how the data is scaled - it only affects the appearance of the legend.

labels

NULL for no labels, waiver() for default labels (labels the same as breaks), a character vector the same length as breaks, or a named character vector whose names are used to match replacement the labels for matching breaks.

limits

A character vector specifying the data range for the scale. and the default order of their display in guides.

expand

a numeric vector of length two, giving a multiplicative and additive constant used to expand the range of the scales so that there is a small gap between the data and the axes. The defaults are (0,0.6) for discrete scales and (0.05,0) for continuous scales.

na.value

how should missing values be displayed?

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

the name of, or actual function, used to create the guide. See guides for more info.


animint2

Animated Interactive Grammar of Graphics

v2020.9.18
GPL-3
Authors
Toby Hocking [aut, cre] (Original animint code), Hadley Wickham [aut] (Forked ggplot2 code), Winston Chang [aut] (Forked ggplot2 code), RStudio [cph] (Forked ggplot2 code), Nicholas Lewin-Koh [aut] (hexGrob), Martin Maechler [aut] (hexGrob), Randall Prium [aut] (cut_width), Susan VanderPlas [aut] (Animint GSOC 2013), Carson Sievert [aut] (Animint GSOC 2014), Kevin Ferris [aut] (Animint GSOC 2015), Jun Cai [aut] (Animint GSOC 2015), Faizan Khan [aut] (Animint GSOC 2016-2017), Vivek Kumar [aut] (Animint GSOC 2018), Himanshu Singh [aut] (Animint2 GSoC 2020)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.