ecdf_plot {esvis} | R Documentation |
Empirical Cumulative Distribution Plot
Description
This is a wrapper function for the stat_ecdf function and helps make it easy to directly compare distributions at specific locations along the scale.
Usage
ecdf_plot(
data,
formula,
cuts = NULL,
linewidth = 1.2,
ref_line_cols = "gray40",
ref_linetype = "solid",
center = FALSE,
ref_rect = TRUE,
ref_rect_col = "gray40",
ref_rect_alpha = 0.15
)
Arguments
data |
A tidy data frame containing the data to be plotted. |
formula |
A formula of the type |
cuts |
Optional numeric vector stating the location of reference line(s) and/or rectangle(s). |
linewidth |
Width of ECDF lines. Note that the color of the lines can
be controlled through additional functions (e.g., |
ref_line_cols |
Optional vector (or single value) of colors for
|
ref_linetype |
Optional vector (or single value) of line types for
|
center |
Logical. Should the functions be centered prior to plotting?
Defaults to |
ref_rect |
Logical, defaults to |
ref_rect_col |
Color of the fill for the reference rectangles. Defaults to a dark gray. |
ref_rect_alpha |
Transparency of the fill for the reference rectangles. Defaults to 0.7. |
Examples
ecdf_plot(benchmarks, math ~ ell,
cuts = c(190, 205, 210),
ref_line_cols = c("#D68EE3", "#9BE38E", "#144ECA"))
# Customize the plot with ggplot2 functions
library(ggplot2)
ecdf_plot(benchmarks, math ~ ell,
cuts = c(190, 205, 210),
ref_line_cols = c("#D68EE3", "#9BE38E", "#144ECA")) +
theme_minimal() +
theme(legend.position = "bottom")
ecdf_plot(seda, mean ~ grade) +
scale_fill_brewer(palette = "Set2") +
theme_minimal()
# Use within the dplyr pipeline
library(dplyr)
benchmarks %>%
mutate(season = factor(season,
levels = c("Fall", "Winter", "Spring"))) %>%
ecdf_plot(math ~ ell + season + frl)