Skip to contents

This base::plot() method is a utility to plot probabilities obtained with Pr(), as well as their variabilities. The probabilities are plotted either against Y, with one curve for each value of X, or vice versa.

Usage

# S3 method for class 'probability'
plot(
  x,
  variability = NULL,
  subset = NULL,
  PvsY = NULL,
  legend = "top",
  lty = c(1, 2, 4, 3, 6, 5),
  lwd = 2,
  col = palette(),
  type = NULL,
  alpha.f = 1,
  var.alpha.f = NULL,
  xlab = NULL,
  ylab = NULL,
  main = NULL,
  ylim = c(0, NA),
  grid = TRUE,
  add = FALSE,
  ...
)

Arguments

x

Object of class "probability", obtained with Pr().

variability

One of the values 'quantiles', 'samples', 'none' (equivalent to NA or FALSE), or NULL (default), in which case the variability available in p is used. This argument chooses how to represent the variability of the probability; see Pr(). If the requested variability is not available in the object p, then a warning is issued and no variability is plotted.

subset

Named list or named vector: which variate values to display. For the variates corresponding to the names in this list, only the vector of values corresponding to that variate is displayed.

PvsY

Logical or NULL: should probabilities be plotted against their Y argument? If NULL, the argument between Y and X having larger number of values is chosen. As many probability curves will be plotted as the number of values of the other argument.

legend

One of the values 'bottomright', 'bottom', 'bottomleft', 'left', 'topleft', 'top', 'topright', 'right', 'center' (see graphics::legend()): plot a legend at that position. A value FALSE or any other does not plot any legend. Default 'top'.

lty, lwd, col, type, xlab, ylab, main, ylim, grid, add

see analogous arguments in graphics::matplot()

alpha.f

Numeric, default 0.25: opacity of the colours, 0 being completely invisible and 1 completely opaque.

var.alpha.f

Numeric: opacity of the quantile bands or of the samples, 0 being completely invisible and 1 completely opaque.

...

Other parameters to be passed to flexiplot().

Value

NULL, invisibly; produces a plot, see graphics::matplot().

See also

Pr() to calculate posterior probabilities and quantiles.

hist.probability() to plot the variability of the probabilities as a distribution.

flexiplot() (on which plot.probability() is based) for more general plots.

plotquantiles() to plot quantile ranges.

Examples

## Load the example `learnt` object calculated from the "penguins" dataset;
## variates: 'species' and 'bill_len'
learnt <- learntExample

## create a grid of values for variate "bill length",
## based on the information in the dataset and metadata:
values <- vrtgrid(vrt = 'bill_len', learnt = learnt)

## calculate the probabilities and quantiles
probs <- Pr(Y = data.frame(bill_len = values), learnt = learnt, parallel = 1)

## plot the probabilities and quantiles
plot(probs)