Learn R Programming

ggincerta (version 0.1.0)

ScaleExceed: Exceedance probability colour scales

Description

scale_*_exceed computes exceedance probabilities from a specified distribution and maps onto a continuous gradient colour scale.

Usage

ScaleExceed

scale_fill_exceed( name = NULL, palette = "Oranges", type = "seq", direction = 1, dist_fun = NULL, threshold = 1.64, limits = c(0, 1), na.value = NA, guide = "colourbar", aesthetics = "fill", ... )

scale_colour_exceed( name = NULL, palette = "Oranges", type = "seq", direction = 1, dist_fun = NULL, threshold = 1.64, limits = c(0, 1), na.value = NA, guide = "colourbar", aesthetics = "colour", ... )

Value

A ScaleExceed ggproto object.

Format

An object of class ScaleExceed (inherits from ScaleContinuous, Scale, ggproto, gg) of length 2.

Arguments

name

The name of the scale. Used as the axis or legend title. If waiver(), the default, the name of the scale is taken from the first mapping used for that aesthetic. If NULL, the legend title will be omitted.

palette

A palette function that when called with a numeric vector with values between 0 and 1 returns the corresponding output values (e.g., scales::pal_area()).

type

One of "seq" (sequential), "div" (diverging) or "qual" (qualitative)

direction

Sets the order of colours in the scale. If 1, the default, colours are as output by RColorBrewer::brewer.pal(). If -1, the order of colours is reversed.

dist_fun

A function used to compute the exceedance probability. If NULL (the default), a normal distribution with stats::pnorm() is used.

threshold

A numeric value specifying the threshold q in the exceedance probability expression P(X > q).

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()).

na.value

Missing values will be replaced with this value.

guide

A function used to create a guide or its name. See guides() for more information.

aesthetics

The names of the aesthetics that this scale works with.

...

Other arguments passed to ggplot2::continuous_scale().

Examples

Run this code
# Create an exceedance probability scale
sc <- scale_fill_exceed()
class(sc)

# Basic bivariate map
p <- ggplot(nc) + geom_sf(aes(fill = duo_exceed(value, sd)))

Run the code above in your browser using DataLab