hist_boxplot2: Histogram and jittered boxplots partitioned by categories

View source: R/plot_utils.R

hist_boxplot2R Documentation

Histogram and jittered boxplots partitioned by categories

Description

Creates a histogram and jittered boxplot with color-coded, separate distributions for each value of a user-specified categorical variable.

Usage

hist_boxplot2(
  data,
  binsize = diff(range(data[, 1], na.rm = T))/25,
  colors = NULL,
  hist_alpha = 0.75,
  box_fill = "gray50",
  box_alpha = 0.5,
  box_lwd = 1,
  jitter_alpha = 0.75,
  jitter_size = 1.75,
  x_title = "",
  y_title = ""
)

Arguments

data

A two-column data frame with numeric values for plotting in the first column and the categorical variable as the second column.

binsize

A numeric value for the histogram bin widths.

colors

A string vector. The histogram bar colors and jitter colors for each categorical variable value.

hist_alpha

A numeric value for the alpha level for histogram bars.

box_fill

A string. The fill color for the boxplot.

box_alpha

A numeric value for the alpha level for the boxplot.

box_lwd

A numeric value for the boxplot line width.

jitter_alpha

A numeric for the alpha level for jittered data points.

jitter_size

A numeric for the point size for jittered data points.

x_title

A string denoting the x-axis title. Only added to the boxplot.

y_title

A string denoting the y-axis title. Only added to the histogram.

Details

Creates two plots that can be organized as a single column two row multi-figure. The top row plot is multiple overlayed histograms from data partitioned by a variable. The bottom row plot is multiple horizontal boxplots with jittered data points overlayed. The x-axis of both plots are fixed to the same limits for comparability across plots.

Value

A list of two ggplot objects hist and boxplot.

See Also

hist_boxplot


bryancquach/omixjutsu documentation built on Jan. 29, 2023, 3:47 p.m.