View source: R/bcat_plt_hist.R
| bcat_plt_hist | R Documentation |
Create a histogram using ggplot2 graphics with UC styling. Includes optional density curve overlay and mean reference line.
bcat_plt_hist(
df,
x,
bins = NULL,
fill = palette_UC[["Steger Silver"]],
facet = NULL,
density = FALSE,
mean_line = TRUE,
rug = FALSE,
x_lab = ggplot2::waiver(),
y_lab = ggplot2::waiver(),
title = ggplot2::waiver(),
subtitle = ggplot2::waiver(),
caption = ggplot2::waiver(),
legend_position = "bottom",
legend_hide = FALSE,
x_scale = NULL,
y_scale = NULL,
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 |
Variable to map to the x-axis. |
bins |
Number of bins. If NULL (default), uses ggplot2's automatic selection. |
fill |
Fill color for bars. Default is UC Steger Silver. |
facet |
Facetting variable(s). Wrap in |
density |
Logical. Overlay density curve? Default is FALSE. |
mean_line |
Logical. Draw dashed vertical line at mean? Default is TRUE. |
rug |
Logical. Add rug plot at bottom? Default is FALSE. |
x_lab |
Label for x-axis. |
y_lab |
Label for y-axis. |
title |
Plot title. |
subtitle |
Plot subtitle. |
caption |
Plot caption. |
legend_position |
Legend position: |
legend_hide |
Logical. Hide legend? |
x_scale |
|
y_scale |
|
facet_scale |
Facet scales: |
nrow |
Number of facet rows. |
ncol |
Number of facet columns. |
x_refline |
Vector of x-values for vertical reference lines. |
y_refline |
Vector of y-values for horizontal reference lines. |
A ggplot object.
Saannidhya Rawat
Other plots:
bcat_plt_area(),
bcat_plt_bar(),
bcat_plt_box(),
bcat_plt_coef(),
bcat_plt_diag(),
bcat_plt_line(),
bcat_plt_point(),
bcat_plt_ts()
library(ggplot2)
# Basic histogram
bcat_plt_hist(mtcars, x = mpg)
# With density curve and mean line
bcat_plt_hist(mtcars, x = mpg, density = TRUE, mean_line = TRUE)
# Faceted by cylinders
bcat_plt_hist(mtcars, x = mpg, facet = vars(cyl), facet_scale = "free_x")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.