Learn R Programming

mistr (version 0.0.6)

plotgg: Autoplot of Distributions Using ggplot2

Description

The function plotgg plots the CDF and PDF of a given distribution object.

Usage

plotgg(x, which = "all", ...)

# S3 method for contdist plotgg( x, which = "all", pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1, size2 = 1, alpha1 = 0.7, alpha2 = 0.7, ... )

# S3 method for trans_contdist plotgg( x, which = "all", pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1, size2 = 1, alpha1 = 0.7, alpha2 = 0.7, ... )

# S3 method for discrdist plotgg( x, which = "all", col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PMF", size1 = 3.3, size2 = 3.3, alpha1 = 0.9, alpha2 = 0.9, col_segment = "#b05e0b", ... )

# S3 method for trans_discrdist plotgg( x, which = "all", col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PMF", size1 = 3.3, size2 = 3.3, alpha1 = 0.9, alpha2 = 0.9, col_segment = "#b05e0b", ... )

# S3 method for contmixdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1, size2 = 1, alpha1 = 0.4, alpha2 = 0.4, legend.position1 = "none", legend.position2 = "none", ... )

# S3 method for trans_contmixdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1, size2 = 1, alpha1 = 0.4, alpha2 = 0.4, legend.position1 = "none", legend.position2 = "none", ... )

# S3 method for discrmixdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PMF", size1 = 1.6, size2 = 1.6, alpha1 = 0.4, alpha2 = 0.9, legend.position1 = "none", legend.position2 = "none", width = 0.25, ... )

# S3 method for trans_discrmixdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PMF", size1 = 1.6, size2 = 1.6, alpha1 = 0.4, alpha2 = 0.9, legend.position1 = "none", legend.position2 = "none", width = 0.25, ... )

# S3 method for contdiscrmixdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1.6, size2 = 1.6, alpha1 = 0.4, alpha2 = 0.4, legend.position1 = "none", legend.position2 = "none", ... )

# S3 method for trans_contdiscrmixdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1.6, size2 = 1.6, alpha1 = 0.4, alpha2 = 0.4, legend.position1 = "none", legend.position2 = "none", ... )

# S3 method for compdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1.6, size2 = 1.6, alpha1 = 0.4, alpha2 = 0.4, legend.position1 = "none", legend.position2 = "none", text_ylim = -0.01, col_segment = "white", lty_segment = 3, lwd_segment = 1.8, ... )

# S3 method for trans_compdist plotgg( x, which = "all", only_mix = FALSE, pp1 = 1000, pp2 = 1000, col = "#F9D607", xlim1 = q(x, c(0.01, 0.99)), ylim1 = NULL, xlim2 = xlim1, ylim2 = NULL, xlab1 = NULL, ylab1 = NULL, xlab2 = NULL, ylab2 = NULL, main1 = "CDF", main2 = "PDF", size1 = 1.6, size2 = 1.6, alpha1 = 0.4, alpha2 = 0.4, legend.position1 = "none", legend.position2 = "none", text_ylim = -0.01, col_segment = "white", lty_segment = 3, lwd_segment = 1.8, ... )

Value

ggplot object if which = "cdf" or which = "pdf". If both are plotted, the plots are merged using multiplot() function and a list with both plots is invisibly returned.

Arguments

x

distribution object.

which

whether to plot only CDF, PDF or both, default: 'all'.

...

further arguments to be passed.

pp1

number of points at which CDF is evaluated, default: 1000.

pp2

number of points at which PDF is evaluated, default: 1000.

col

color used in plot, default: '#122e94'.

xlim1

xlim of CDF plot, default: q(x, c(0.01, 0.99)).

ylim1

ylim of CDF plot, default: NULL.

xlim2

xlim of PDF plot, default: xlim1.

ylim2

ylim of PDF plot, default: NULL.

xlab1

xlab of CDF plot, default: NULL.

ylab1

ylab of CDF plot, default: NULL.

xlab2

xlab of PDF plot, default: NULL.

ylab2

ylab of PDF plot, default: NULL.

main1

title of CDF plot, default: 'CDF'.

main2

title of PDF plot, default: 'PDF'/'PMF'.

size1

size used in CDF plot.

size2

size used in PDF plot.

alpha1

alpha used in CDF plot.

alpha2

alpha used in PDF plot.

col_segment

col of additional segment if contained in the plot (composite and discrete distributions).

only_mix

whether to plot only mixture/composite model and not also the components, default: FALSE.

legend.position1

legend.position used in CDF plot.

legend.position2

legend.position used in PDF plot.

width

width of the bars that are used to plot discrete mixtures, default: 0.25.

text_ylim

y coordinate for text annotation, default: -0.01.

lty_segment

lty of additional segment if contained in the plot (composite and discrete distributions).

lwd_segment

lwd of additional segment if contained in the plot (composite and discrete distributions).

Examples

Run this code
if (FALSE) {
N <- normdist()
autoplot(N)

# manipulating cdf plot
B <- binomdist(12, 0.5)
autoplot(-3*B, which = "cdf", xlim1 = c(-30, -10))
# manipulating pdf plot
autoplot(-3*B, which = "pdf", xlim2 = c(-30, -10))
}

Run the code above in your browser using DataLab