Six plots, which can be selected with fun
are available for discrete and
continuous univariate distributions: pdf, cdf, quantile, survival, hazard and cumulative
hazard. By default, the first two are plotted side by side.
distr6
object.
vector of functions to plot, one or more of: "pdf","cdf","quantile", "survival", "hazard", "cumhazard", and "all"; partial matching available.
number of evaluation points.
logical; if TRUE (default), figures are displayed in the plot window; otherwise a
data.table::data.table()
of points and calculated values is returned.
logical; if TRUE, the user is asked before each plot, see graphics::par()
.
logical; if TRUE (default), margins are automatically adjusted with
graphics::layout()
to accommodate all plotted functions.
graphical parameters, see details.
The evaluation points are calculated using inverse transform on a uniform grid between 0 and 1
with length given by npoints
. Therefore any distribution without an analytical quantile
method will first need to be imputed with the FunctionImputation decorator.
The order that the functions are supplied to fun
determines the order in which they are
plotted, however this is ignored if ask
is TRUE
. If ask
is TRUE
then
arrange
is ignored. For maximum flexibility in plotting layouts, set arrange
and
ask
to FALSE
.
The graphical parameters passed to ...
can either apply to all plots or selected plots.
If parameters in par
are prefixed with the plotted function name, then
the parameter only applies to that function, otherwise it applies to them all. See examples for
a clearer description.
if (FALSE) { # \dontrun{
# Plot pdf and cdf of Normal
plot(Normal$new())
# Colour both plots red
plot(Normal$new(), col = "red")
# Change the colours of individual plotted functions
plot(Normal$new(), pdf_col = "red", cdf_col = "green")
# Interactive plotting in order - par still works here
plot(Geometric$new(),
fun = "all", ask = TRUE, pdf_col = "black",
cdf_col = "red", quantile_col = "blue", survival_col = "purple",
hazard_col = "brown", cumhazard_col = "yellow"
)
# Return plotting structure
x <- plot(Gamma$new(), plot = FALSE)
} # }