plot_pdensity: Quickly plot probability density function

View source: R/plot_pdensity.R

plot_pdensityR Documentation

Quickly plot probability density function

Description

Quickly plot probability density function

Usage

plot_pdensity(
  fun,
  x = NULL,
  color = "skyblue",
  linetype = "solid",
  size = 1.5,
  fill = NA,
  alpha = 0.3,
  location = 0,
  p_limit = 0.001,
  lower_bound = -10000,
  upper_bound = 10000,
  ...
)

Arguments

fun

A probability density function (e.g. dnorm).

x

(Optional) A sequence of values for the probability density function. If not supplied, the function will be plotted for all points with probability density greater than p_limit (default 0.001) between the lower_bound (default -10000) and the upper_bound (default 10000).

color

The color of the plotted line (default "skyblue").

linetype

The linetype (default "solid").

size

The size of the line (default 1.5).

fill

The color of the fill under the line (default NA = no fill)

alpha

The alpha transparency for the fill (default 0.3).

location

For probability density functions that do not have a location parameter, this will shift the center (zero) of that distribution to the specified location.

p_limit

The probability density cutoff for plotting.

lower_bound

The (potential) lower range of plotting subject to the p_limit cutoff (default -10000).

upper_bound

The (potential) upper range of plotting subject to the p_limit cutoff (default 10000).

...

Any additional parameters will be passed to the probability density function

Value

A ggplot gg object.

Examples

plot_pdensity(dnorm)
plot_pdensity(dnorm, seq(-3, 3, length.out = 100))
plot_pdensity(dbeta, shape1 = 2, shape2 = 2)

ryanraaum/plotpriors documentation built on March 31, 2022, 3:24 a.m.