Plot a distribution as a hybrid containing a halfeye, a boxplot and jittered points.
plot_dist(
dat,
yvar,
xvar = NULL,
ylim = NULL,
xlb = "",
ylb = "",
identity_line = FALSE,
identity_value = 0,
he_adjust = 0.5,
he_width = 0.6,
he_justification = -0.2,
he_col = "black",
he_fill = "#F8766D",
he_alpha = 0.9,
he_slab_type = "pdf",
he_breaks = "Sturges",
he_outline_bars = FALSE,
he_point_interval = "median_qi",
bxp_width = 0.12,
bxp_outlier_col = NA,
bxp_outlier_fill = NA,
bxp_outlier_shape = 19,
bxp_outlier_size = 1.5,
bxp_col = "black",
bxp_fill = "#F8766D",
bxp_alpha = 0.9,
bxp_notch = FALSE,
bxp_notchwidth = 0.5,
hp_range_scale = 0.4,
hp_alpha = 0.25,
hp_col = "#F8766D",
hp_transformation = position_jitter(),
na.rm = FALSE
)
A plot containing jittered points, a boxplot and a density plot or histogram illustrating the distribution of every group of the data under evaluation.
A data frame.
The name of the field containing values to be plotted.
The name of the field containing the grouping variable (defaults to `NULL`).
Limits for the y-axis. Defaults to NULL
. If provided, should be a 2-element vector containing the upper and lower limits.
Label for the x-axis.
Label for the y-axis.
Show a line of identity? Default FALSE
.
If an identity line is shown, it will be drawn horizontally at this y-value (default 0).
If he_slab_type
is "pdf"
, bandwidth for the density estimator is adjusted by multiplying it by this value.
Width of the halfeye component of the plot (default 0.6).
Justification of the halfeye component of the plot (default -0.2).
Color for the halfeye component of the plot.
Fill color for the halfeye component of the plot.
Alpha for the halfeye component of the plot (default 0.9).
The type of slab function to calculate for the halfeye component of the plot: probability density (or mass) function ("pdf"
, the default), cumulative distribution function ("cdf"
), complementary CDF ("ccdf"
) or histogram ("histogram"
).
If slab_type is "histogram"
, the breaks parameter that is passed to hist()
to determine where to put breaks in the histogram.
If slab_type is "histogram"
, determines if outlines in between the bars are drawn when the slab_color aesthetic is used. If FALSE
(the default), the outline is drawn only along the tops of the bars; if TRUE
, outlines in between bars are also drawn.
A function from the ggdist::point_interval
family (e.g., median_qi
, mean_qi
, mode_hdi
, etc), or a string giving the name of a function from that family (e.g., "median_qi"
, "mean_qi"
, "mode_hdi"
, etc. This function determines the point summary (typically mean, median, or mode) and interval type (quantile interval, qi
; highest-density interval, hdi
; or highest-density continuous interval, hdci
). Output will be converted to the appropriate x- or y-based aesthetics depending on the value of orientation.
Width of the boxplot component (default 0.12).
Color for outliers in the boxplot component.
Fill color for outliers in the boxplot component.
Shape for outliers in the boxplot component.
Size for outliers in the boxplot component.
Color for the boxplot component.
Fill color for the boxplot component.
Alpha for the boxplot component.
If FALSE
(default) make a standard box plot. If TRUE
, make a notched box plot. Notches are used to compare groups; if the notches of two boxes do not overlap, this suggests that the medians are significantly different.
For a notched box plot, width of the notch relative to the body (default 0.5).
If no `width` argument is specified in hp_transformation
, used to determine the width of the jitter. Defaults to 0.75, which is half of the allotted space for the jitter-points, whereas 1 would use all of the alotted space.
Alpha for the jitter.
Color for the jitter.
An evaluated position_*()
function yielding a `Position` object with specified parameters to calculate the transformation of the points. Defaults to ggplot2::position_jitter
.
If FALSE
, the default, missing values are removed with a warning. If TRUE
, missing values are silently removed.
Justin Wilkins, justin.wilkins@occams.com
if (FALSE) {
plot_dist(dat, "ETA1", identity_line = T, he_slab_type = "histogram", he_breaks = 30)
}
Run the code above in your browser using DataLab