plot_distribution: Plot a distribution function. Mostly for use with making...

View source: R/plot-distribution.R

plot_distributionR Documentation

Plot a distribution function. Mostly for use with making prior plots for MCMC parameters. See plot_priors_posts_mcmc()

Description

Plot a distribution function. Mostly for use with making prior plots for MCMC parameters. See plot_priors_posts_mcmc()

Usage

plot_distribution(
  fun = dnorm,
  nsamp = 100,
  param_lst = list(mean = 0, sd = 0.5),
  xlim = c(-2, 2),
  fill = "steelblue",
  title = "",
  mode_line_col = "red",
  mode_line_lwd = 0.5,
  mode_line_lty = 1,
  mean_line_col = "black",
  mean_line_lwd = 0.5,
  mean_line_lty = 1,
  sd_lines_col = "black",
  sd_lines_lwd = 0.5,
  sd_lines_lty = 2,
  alpha = 0.75,
  show_mode_line = TRUE,
  show_mean_line = TRUE,
  show_sd_lines = TRUE
)

Arguments

fun

The function to plot

nsamp

Number of points across x-axis

param_lst

A list of parameters required by the function provided (fun) They can be named but do not have to be

xlim

x-axis limits (2-element vector)

fill

Fill color for under the curve

title

Plot title

mode_line_col

Mode line color

mode_line_lwd

Mode line width

mode_line_lty

Mode line type

mean_line_col

Mean line color

mean_line_lwd

Mean line width

mean_line_lty

Mean line type

sd_lines_col

Standard deviation lines color

sd_lines_lwd

Standard deviation lines width

sd_lines_lty

Standard deviation lines type

alpha

Opacity of fill from 0-1

show_mode_line

Logical. If TRUE, show a vertical line at the mode of the distribution

show_mean_line

Logical. If TRUE, show a vertical line at the mean

show_sd_lines

Logical. If TRUE, show vertical lines one standard deviation away from the mean

Details

The plot will contain a filled curve representing the prior distribution, and a solid red (mode_line_col) vertical line representing the mode of the distribution and a solid black (mean_line_col) and two dotted black (sd_lines_col) vertical lines representing the mean and one standard deviation from the mean

Value

a ggplot2::ggplot() object


pbs-assess/gfiscamutils documentation built on Oct. 24, 2024, 1:37 p.m.