Jittered points plot type

Description

Type function for plotting jittered points. Arguments are passed to jitter.

Usage

type_jitter(factor = 1, amount = NULL)

Arguments

factor numeric; used in calculation of amount when the provided amount is 0 or NULL.
amount number or NULL; when positive, specifies the amount of jitter; see Details, also for other cases.

Details

The result of r <- x + amount * runif(n, -1, 1) where n <- length(x).

When amount is NULL (the default) amount <- factor * d/5 where d is about the smallest difference between adjacent unique (up to fuzz) x values.

If amount == 0, amount <- factor * (max(x) - min(x))/50, (using only finite x values), which is the same as in S and the references. In the above cases, the final amount is always ensured to be positive.

The short jitter() function is itself a succinct definition.

Examples

library("tinyplot")

# "jitter" type convenience string
tinyplot(Sepal.Length ~ Species, data = iris, type = "jitter")

# Use `type_jitter()` to pass extra arguments for customization
tinyplot(Sepal.Length ~ Species, data = iris, type = type_jitter(factor = 0.5))