| bcat_plt_box | R Documentation |
Create a box plot or violin plot with UC styling. Includes optional jittered point overlay and outlier highlighting.
bcat_plt_box(
df,
x,
y,
fill = NULL,
facet = NULL,
violin = FALSE,
jitter = TRUE,
jitter_width = 0.2,
notch = FALSE,
order = FALSE,
coord_flip = FALSE,
alpha = 0.3,
x_lab = ggplot2::waiver(),
y_lab = ggplot2::waiver(),
title = ggplot2::waiver(),
subtitle = ggplot2::waiver(),
caption = ggplot2::waiver(),
legend_lab = ggplot2::waiver(),
legend_position = "bottom",
legend_hide = FALSE,
x_scale = NULL,
y_scale = NULL,
fill_scale = scale_fill_UC(),
facet_scale = c("fixed", "free_y", "free_x", "free"),
nrow = NULL,
ncol = NULL,
x_refline = NULL,
y_refline = NULL
)
df |
The data to be displayed. |
x |
Categorical variable for the x-axis. |
y |
Numeric variable for the y-axis. |
fill |
Variable to map to fill aesthetic. If NULL, uses x for coloring. |
facet |
Facetting variable(s). Wrap in |
violin |
Logical. Use violin plot instead of box plot? Default is FALSE. |
jitter |
Logical. Overlay jittered points? Default is TRUE. |
jitter_width |
Jitter width. Default is 0.2. |
notch |
Logical. Add notches? Default is FALSE. |
order |
Logical. Reorder x by median of y? Default is FALSE. |
coord_flip |
Logical. Flip coordinates? Default is FALSE. |
alpha |
Point transparency. Default is 0.3. |
x_lab |
Label for x-axis. |
y_lab |
Label for y-axis. |
title |
Plot title. |
subtitle |
Plot subtitle. |
caption |
Plot caption. |
legend_lab |
Legend title. |
legend_position |
Legend position. |
legend_hide |
Logical. Hide legend? |
x_scale |
|
y_scale |
|
fill_scale |
|
facet_scale |
Facet scales. |
nrow |
Number of facet rows. |
ncol |
Number of facet columns. |
x_refline |
Vertical reference lines. |
y_refline |
Horizontal reference lines. |
A ggplot object.
Saannidhya Rawat
Other plots:
bcat_plt_area(),
bcat_plt_bar(),
bcat_plt_coef(),
bcat_plt_diag(),
bcat_plt_hist(),
bcat_plt_line(),
bcat_plt_point(),
bcat_plt_ts()
library(ggplot2)
# Basic box plot
bcat_plt_box(mtcars, x = factor(cyl), y = mpg)
# Violin plot
bcat_plt_box(mtcars, x = factor(cyl), y = mpg, violin = TRUE)
# Ordered and flipped
bcat_plt_box(mtcars, x = factor(cyl), y = mpg, order = TRUE, coord_flip = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.