Skip to contents

`r lifecycle::badge("deprecated")` This function is deprecated. Please use `margot_plot_categorical()` instead.

Usage

coloured_histogram_quantiles(
  df,
  col_name,
  n_divisions = NULL,
  breaks = NULL,
  binwidth = NULL,
  n_bins = NULL,
  cutpoint_inclusive = "upper",
  ties.method = NULL,
  colours = NULL,
  hist_fill = "lightgray",
  hist_colour = "black",
  line_type = "solid",
  line_width = 0.75,
  title = NULL,
  subtitle = NULL,
  x_lab = NULL,
  y_lab = "Count",
  theme_choice = theme_classic(),
  text_size = 12,
  axis_text_angle = 45,
  add_density = FALSE,
  add_rug = FALSE,
  facet_var = NULL,
  x_scale_transform = NULL,
  y_scale_transform = NULL,
  additional_layers = NULL
)

Arguments

df

dataframe containing the data to be visualised

col_name

name of the column to create a histogram for

n_divisions

the number of divisions to create. if null, user must provide breaks

breaks

optional. a numeric vector specifying custom breakpoints

binwidth

width of the bins for the histogram

n_bins

optional. number of bins for the histogram. overrides binwidth if specified

cutpoint_inclusive

a character string specifying whether cutpoints should be included in the lower or upper category. must be either "lower" or "upper". default is "upper"

ties.method

a character string specifying how ties should be handled

colours

optional. a vector of colours for the quantile lines

hist_fill

colour for histogram fill. default is "lightgray"

hist_colour

colour for histogram outline. default is "black"

line_type

line type for quantile lines. default is "solid"

line_width

line width for quantile lines. default is 0.75

title

custom title for the plot. if null, a default title is used

subtitle

custom subtitle for the plot. if null, a default subtitle is used

x_lab

custom x-axis label. if null, the column name is used

y_lab

custom y-axis label. default is "count"

theme_choice

ggplot2 theme to use. default is theme_classic()

text_size

base text size for the plot. default is 12

axis_text_angle

angle for x-axis text. default is 45

add_density

logical. if true, adds a density curve to the plot

add_rug

logical. if true, adds a rug plot to the x-axis

facet_var

optional. name of variable to use for faceting

x_scale_transform

optional. transformation for x-axis (e.g., "log10")

y_scale_transform

optional. transformation for y-axis (e.g., "log10")

additional_layers

optional list of additional ggplot2 layers to add to the plot

Value

a ggplot object representing the histogram with highlighted quantiles