scale_show_infinites_y: Include Infinite Values in Plot

View source: R/scales.R

scale_show_infinites_yR Documentation

Include Infinite Values in Plot

Description

Will replace infinite values by the nearest limit.

Usage

scale_show_infinites_y(
  trans = "identity",
  limits = NULL,
  position = "bottom",
  breaks = ggplot2::waiver(),
  ...
)

Arguments

trans

For continuous scales, the name of a transformation object or the object itself. Built-in transformations include "asn", "atanh", "boxcox", "date", "exp", "hms", "identity", "log", "log10", "log1p", "log2", "logit", "modulus", "probability", "probit", "pseudo_log", "reciprocal", "reverse", "sqrt" and "time".

A transformation object bundles together a transform, its inverse, and methods for generating breaks and labels. Transformation objects are defined in the scales package, and are called <name>_trans (e.g., scales::boxcox_trans()). You can create your own transformation with scales::trans_new().

limits

One of:

  • NULL to use the default scale range

  • A numeric vector of length two providing limits of the scale. Use NA to refer to the existing minimum or maximum

  • A function that accepts the existing (automatic) limits and returns new limits. Also accepts rlang lambda function notation. Note that setting limits on positional scales will remove data outside of the limits. If the purpose is to zoom, use the limit argument in the coordinate system (see coord_cartesian()).

position

For position scales, The position of the axis. left or right for y axes, top or bottom for x axes.

breaks

One of:

  • NULL for no breaks

  • waiver() for the default breaks computed by the transformation object

  • A numeric vector of positions

  • A function that takes the limits as input and returns breaks as output (e.g., a function returned by scales::extended_breaks()). Also accepts rlang lambda function notation.

...

Arguments passed on to scale_show_infinites_x

Value

ScaleContinuousPosition object that can be added to a ggplot object using '+'

See Also

scale_show_infinites_x()

Examples

## Not run: 
data = mtcars %>%
    dplyr::mutate(qsec2 = ifelse(qsec > 19, Inf, qsec))

# Plot with infinites set to nearest limit
data %>%
    ggplot2::ggplot(ggplot2::aes(x=carb, y=qsec2)) +
    ggplot2::geom_point() +
    scale_show_infinites_y()

# Plot on a log10 scale with infinites set to nearest limit
data %>%
    ggplot2::ggplot(ggplot2::aes(x=carb, y=qsec2)) +
    ggplot2::geom_point() +
    scale_show_infinites_y(trans="log10")

## End(Not run)

selkamand/utilitybeltgg documentation built on July 14, 2022, 2:32 p.m.