View source: R/plot_fitverse.R
| plot.fitverse | R Documentation |
fitverse ObjectProduces a two-panel diagnostic figure for a fitted fitverse object:
A histogram of the data overlaid with the fitted density curves for the top-ranked distributions. The PDF formula is annotated directly on the figure.
A Q-Q plot of the empirical quantiles against theoretical quantiles from the best-fit distribution.
Either or both panels can be requested. The plot can optionally be returned as an interactive plotly HTML widget.
## S3 method for class 'fitverse'
plot(x,
which = "both",
top_n = 3L,
xlab = NULL,
interactive = FALSE,
draw = TRUE,
...)
x |
An object of class |
which |
Character scalar controlling which panels to draw. One of:
|
top_n |
Integer: number of top-ranked models to overlay on the density panel.
The best-fit model is drawn as a solid line; others as dashed lines
with distinct colours. Default |
xlab |
Character: x-axis label. If |
interactive |
Logical: if |
draw |
Logical: if |
... |
Currently unused; reserved for future extensions. |
The density panel uses ggplot2::geom_histogram(aes(y = after_stat(density)))
with Freedman-Diaconis binning, overlaid with geom_line() curves
evaluated on a fine grid of 512 points spanning the observed data range.
The Q-Q panel compares theoretical quantiles from the best-fit distribution
(evaluated via qfitverse()) against the empirical quantiles of
the data, with a 45-degree reference line.
When which = "both", the two ggplot2 objects are arranged side-by-side
using gridExtra::grid.arrange(). When interactive = TRUE and
which != "both", a single panel is converted with
plotly::ggplotly().
Invisibly returns the plot object(s):
A single ggplot2 object when which is "density" or "qq".
A grob (arranged grid object) when which = "both".
A plotly widget when interactive = TRUE.
Karuna G. Reddy karuna.reddy@auckland.ac.nz
M. G. M. Khan mgm.khan@usp.ac.fj
save_plot to write the figure to a PNG or PDF file.
fitverse which calls this function automatically when plot = TRUE.
set.seed(42)
x <- rgamma(300, shape = 2, rate = 0.5)
fit <- fitverse(x, plot = FALSE, verbose = FALSE)
# Both panels (default)
plot(fit)
# Density panel only with custom x-axis label
plot(fit, which = "density", xlab = "Value", top_n = 5)
# Q-Q plot only
plot(fit, which = "qq")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.