plot_hpd: plot_hpd

Description Usage Arguments See Also Examples

Description

Plot a univariate density with its hpd shaded

Usage

1
2
plot_hpd(x, dens, hpd, col1 = "gray50", col2 = "gray50", multiply = TRUE,
  fade = 1, add = FALSE, ...)

Arguments

x

Vector of samples to be plotted

dens

Density object of x (optional)

hpd

Vector containing end points of the hpd region, must have an even length (optional)

col1

Color of the non-shaded portion of the plot

col2

Color of the shaded portion

multiply

Logical, if true multiply col1 with col2 and set new color to col2, otherwise don't

fade

Numeric in [0, 1], the degree of transparency to affect col1 and col2, ranging from 0 (totally transparent) to 1 (opaque), defaults to 1

add

Logical, should the plot be added to the current one

...

Extra arguments to pass to plot()

See Also

hpd_uni, hpd_mult, col_dens, col_mult, col_fade

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x = rnorm(100)
y = rnorm(100, 1)
hpd.x = hpd_uni(x)
hpd.y = hpd_uni(y)

# x and y on their own plots
plot_hpd(x, col1 = "dodgerblue")
plot_hpd(y, col1 = "firebrick1")

# together on one plot
plot_hpd(x, col1 = "dodgerblue", fade = 0.6)
plot_hpd(y, col1 = "firebrick1", fade = 0.6, add = TRUE)

mickwar/mwbase documentation built on May 22, 2019, 9:56 p.m.