plotgg: Autoplot of Distributions Using ggplot2

View source: R/plots.R

plotggR Documentation

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 class '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 class '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 class '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 class '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 class '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 class '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 class '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 class '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 class '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 class '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 class '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 class '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,
  ...
)

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).

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.

Examples

## Not run: 
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))

## End(Not run)

mistr documentation built on March 7, 2023, 7:42 p.m.