| plot_qq | R Documentation |
Create a quantile-quantile plot for one or more numeric variables.
plot_qq(
data,
x,
facet_var = NULL,
facet_scale = "free",
facet_nrow = NULL,
facet_ncol = NULL,
color = NULL,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
caption = NULL,
point_size = 2,
point_shape = 16,
point_color = "grey35",
point_fill = "grey35",
point_alpha = 0.25,
line_width = 0.25,
line_type = "solid",
line_color = "grey35",
line_alpha = 1,
band_color = "grey35",
band_alpha = 0.25,
theme_set = theme_tscv(),
theme_config = list(),
...
)
data |
A |
x |
Unquoted column in |
facet_var |
Optional unquoted column in |
facet_scale |
Character value defining facet axis scaling. Common values
are |
facet_nrow |
Optional integer. Number of rows in the facet layout. |
facet_ncol |
Optional integer. Number of columns in the facet layout. |
color |
Optional unquoted column in |
title |
Character value. Plot title. |
subtitle |
Character value. Plot subtitle. |
xlab |
Character value. Label for the x-axis. |
ylab |
Character value. Label for the y-axis. |
caption |
Character value. Plot caption. |
point_size |
Numeric value defining the point size. |
point_shape |
Numeric or character value defining the point shape. |
point_color |
Character value defining the point outline color. Ignored
when |
point_fill |
Character value defining the point fill color. Ignored when
|
point_alpha |
Numeric value between |
line_width |
Numeric value defining the qq-line width. |
line_type |
Character or numeric value defining the qq-line type. |
line_color |
Character value defining the qq-line color. Ignored when
|
line_alpha |
Numeric value between |
band_color |
Character value defining the confidence-band fill color.
Ignored when |
band_alpha |
Numeric value between |
theme_set |
A complete |
theme_config |
A named |
... |
Further arguments passed to |
plot_qq() is a convenience wrapper around the qqplotr
functions stat_qq_point(), stat_qq_line(), and
stat_qq_band(). It is useful for checking whether values, residuals,
or forecast errors approximately follow a theoretical distribution.
By default, the function creates a normal quantile-quantile plot with pointwise confidence bands.
The arguments x, facet_var, and color are passed as
unquoted column names.
If color is supplied, point colors, line colors, and confidence-band
fills are mapped to that variable. In this case, point_color,
point_fill, line_color, and band_color are ignored.
If color is not supplied, the fixed styling arguments are used.
Additional arguments can be passed to the underlying qqplotr
statistics through ..., for example distributional arguments supported
by qqplotr.
Additional theme settings can be supplied through theme_config. This
should be a named list of arguments passed to ggplot2::theme().
An object of class ggplot.
Other data visualization:
plot_bar(),
plot_density(),
plot_histogram(),
plot_line(),
plot_point(),
scale_color_tscv(),
scale_fill_tscv(),
theme_tscv(),
tscv_cols(),
tscv_pal()
library(dplyr)
data <- M4_monthly_data |>
filter(series %in% c("M23100", "M14395"))
plot_qq(
data = data,
x = value,
facet_var = series,
title = "QQ Plot of M4 Monthly Values",
subtitle = "Normal quantile-quantile plots by series",
xlab = "Theoretical quantiles",
ylab = "Sample quantiles"
)
stats <- data |>
group_by(series) |>
mutate(value_centered = value - mean(value, na.rm = TRUE)) |>
ungroup()
plot_qq(
data = stats,
x = value_centered,
color = series,
title = "QQ Plot of Centered M4 Monthly Values",
subtitle = "Normal quantile-quantile plots by series",
xlab = "Theoretical quantiles",
ylab = "Sample quantiles"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.