violins function

Wrapper around viol() to conveniently plot multiple violins on a single plot, analogous to the behavior of boxplot()

Wrapper around viol() to conveniently plot multiple violins on a single plot, analogous to the behavior of boxplot()

violins( x, data = NULL, group = NULL, wt = NULL, adjustto1 = TRUE, horiz = FALSE, order = NULL, xlab = "", ylab = "", col = "black", fill = "grey", lwd = 1, lty = 1, dscale = 1, xlim = NULL, ylim = NULL, spaces = "_", add = FALSE, ax = TRUE, srt = 45, adj = c(1, 0), na.rm = TRUE, ... )

Arguments

  • x: plotting statistic (numeric vector) or formula object from which a plotting statistic and grouping variable can be extracted (i.e. of form x~group)
  • data: data.frame object containing x and y
  • group: grouping variable
  • wt: optional vector of weights (default=NULL)
  • adjustto1: optional setting whether to adjust weights in each category to sum to 1 (default=TRUE)
  • horiz: logical indicating whether to plot horizontally
  • order: order of factor levels of categorical factor
  • xlab: x axis label
  • ylab: y axis label
  • col: vector of border colors
  • fill: vector of fill colors
  • lwd: vector of line widths
  • lty: vector of line types
  • dscale: density scaling factors (numeric) to apply to individual violins
  • xlim: x limits (data limits used if NULL)
  • ylim: y limits (data limits used if NULL)
  • spaces: character string in group to replace with spaces for labels, if not NULL
  • add: logical whether to add to existing plot (default: FALSE)
  • ax: whether to plot axes
  • srt: angle for categorical axis text rotation
  • adj: adjustment for axis labels (defaults to c(1,0), i.e. top right)
  • na.rm: logical indicating whether to tell viol() to remove NA values (defaults to TRUE)
  • ...: other arguments to pass on to paleoDiv::viol() and plot()

Examples

data.frame(p=rnorm(50), cat=rep(c("A","B","B","B","B"),10))->d violins(p~cat,d)
  • Maintainer: Darius Nau
  • License: GPL (>= 3)
  • Last published: 2025-03-23

Useful links