View source: R/plot_distribution.R
plot.Distribution | R Documentation |
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.
## S3 method for class 'Distribution' plot( x, fun = c("pdf", "cdf"), npoints = 3000, plot = TRUE, ask = FALSE, arrange = TRUE, ... )
x |
|
fun |
vector of functions to plot, one or more of: "pdf","cdf","quantile", "survival", "hazard", "cumhazard", and "all"; partial matching available. |
npoints |
number of evaluation points. |
plot |
logical; if TRUE (default), figures are displayed in the plot window; otherwise a
|
ask |
logical; if TRUE, the user is asked before each plot, see |
arrange |
logical; if TRUE (default), margins are automatically adjusted with
|
... |
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.
Chengyang Gao, Runlong Yu and Shuhan Liu
lines.Distribution
## Not run: # 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) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.