plot_norm: Plot a Normal Distribution with Shading

View source: R/plot_norm.R

plot_normR Documentation

Plot a Normal Distribution with Shading

Description

Draw a normal distribution curve and optional shading of a particular region.

Usage

plot_norm(
  mean = 0,
  sd = 1,
  shadeValues = NULL,
  direction = c("less", "greater", "beyond", "between"),
  col.shade = "cornflowerblue",
  ...
)

Arguments

mean

The mean of the normal distribution to plot (mu)

sd

The standard deviation of the normal distribution to plot (sigma)

shadeValues

Either a single number or a vector of two numbers which identify the boundary or boundaries of the shaded region

direction

A character string (in quotes) indicating the direction from shadeValues to shade under the normal curve. Must be one of "less", "greater", "beyond", or "between". See Details below.

col.shade

The color of the shaded region

...

Other graphical parameters passed to plot (e.g., xlim, main, etc.). Generally, these will not control the shading, only the normal distribution curve.

Details

The direction argument is used to control the region under the normal distribution curve which is shaded. If shadeValues is a single number, direction must be either "less" (in which case the shaded region will be to the left of shadeValues) or "greater" (the shaded region will be to the right of shadeValues).

If shadeValues is a vector, then direction must be either "between" (the region between the two numbers in shadeValues will be shaded) or "beyond" (the region below the smaller and above the larger of the shadeValues will be shaded).

Value

A plot of a normal distribution curve with optional shading.

See Also

plot_t

Examples

# Probability of a value being between 3 and 3.5 in a N(3.39, 0.55) distribution
plot_norm(mean = 3.39, sd = 0.55,
          shadeValues = c(3, 3.5),
          direction = "between",
          col.shade = "forestgreen")

# Probability of a value being greater than 1.96 in a N(0, 1) distributio
plot_norm(shadeValues = 1.96,
          direction = "greater",
          col.shade = "peachpuff")

STATS250SBI/stats250sbi documentation built on March 18, 2022, 1:14 p.m.