vioplotW: Violin-plots version W

View source: R/vioplotW.R

vioplotWR Documentation

Violin-plots version W

Description

This function allows generating Violin plots) using a variety of input formats and offers additional options for colors. Main input may be multiple vectors, a matrix or list of multiple data-elements (entries may be of variable length), individual colors for different sets of data or color-gradients can be specified, and the display of n per set of data was integtated (based on an inspiration from the discussion 'Removing-NAs-from-dataframe-for-use-in-Vioplot' on the forum Nabble). It is also possible to plot pairwise half-violins for easier pairwise-comparisons (using halfViolin="pairwise"). Many arguments are kept similar to vioplot (here, the package vioplot is not required/used).

Usage

vioplotW(
  x,
  ...,
  finiteOnly = TRUE,
  removeEmpty = FALSE,
  halfViolin = FALSE,
  boxCol = "def",
  hh = NULL,
  xlim = NULL,
  ylim = NULL,
  nameSer = NULL,
  cexNameSer = NULL,
  horizontal = FALSE,
  col = "rainbow",
  border = "black",
  xlab = NULL,
  ylab = NULL,
  cexLab = NULL,
  cexAxis = NULL,
  lty = 1,
  pointCol = NULL,
  cexPt = NULL,
  tit = NULL,
  las = 1,
  lwd = 1,
  rectCol = "black",
  at = 0,
  add = FALSE,
  wex = NULL,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

x

(matrix, list or data.frame) data to plot, or first series of data

...

(numeric) additional sets of data to plot

finiteOnly

(logical) eliminate non-finite elements to avoid potential errors (eg when encountering NA)

removeEmpty

(logical) omit empty series (or less than 4 finite numeric entries) of data from plot

halfViolin

(logical or character) decide with TRUE or FALSE if full or only half of violins should be plotted, if "pairwise" always 2 data-sets will be plotted back-to-back

boxCol

(character) decide if boxplot should be adde inside the violin, use "def" for default transparent grey

hh

(numeric, length <4) smoothing parameter (standard deviation to kernel function, if omited anormal optimal smoothing parameter is used); equivalent to argument h in package vioplot ; see also sm.density

xlim

(NULL or numeric, length=2) custom limit on x-axis, see also par

ylim

(NULL or numeric, length=2) custom limit on y-axis, see also par

nameSer

(character) custom label for data-sets or columns (length must match number of data-sets)

cexNameSer

(numeric) size of individual data-series labels as cex-expansion factor (see also par)

horizontal

(logical) orientation of plot

col

(character or integer) custom colors or gradients like 'rainbow', 'grayscale', 'heat.colors', 'topo.colors', 'Spectral' or 'Paired', or you may use colors made by the package colorRamps

border

(character) custom color for figure border

xlab

(character) custom x-axis label

ylab

(character) custom y-axis label

cexLab

(numeric) size of axis labels as cex-expansion factor (see also par)

cexAxis

(numeric) size of numeric y-axis labels as cex-expansion factor (see also par)

lty

(integer) line-type for linear regression line (see also par)

pointCol

(character or numeric) display of median: color (defauly white)

cexPt

(numeric) display of median : size of point as cex-expansion factor (see also par)

tit

(character) custom title to figure

las

(integer) orientation of axis labels (see also par)

lwd

(integer) width of line(s) (see also par)

rectCol

(character) color of rectangle

at

(numeric) custom locoation of data-series names, ie the points at which tick-marks are to be drawn, will be passed to axis, it's length ust match the number of data-sets

add

(logical) add to existing plot if TRUE

wex

(integer) relative expansion factor of the violin

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Details

The (relative) width of the density-profiles ('Violins') may be manually adjusted using the parameter wex which applieds to all profiles drawn. Please note that different n (eg for different columns) will not be shown, so far.

Note : Arguments have to be given with full names, lazy evaluation of arguments will not work properly with this function (since '...' is used to capture additional data-sets). Note : vioplot offers better options for plotting formulas

Value

This function plots a figure (to the current graphical device)

See Also

the package vioplot, sm is used for the density estimation

Examples

set.seed(2013)
dat6 <- matrix(round(rnorm(300) +3, 1), ncol=6,
	 dimnames=list(paste0("li",1:50), letters[19:24]))
vioplotW(dat6)
## variable number of elements (each n is displayed)
dat6b <- apply(dat6, 2, function(x) x[which(x < 5)])
dat6b[[4]] <- dat6b[[4]][dat6b[[4]] < 4]
vioplotW(dat6b, col="Spectral")
vioplotW(dat6b, col="Spectral" ,halfViolin="pairwise", horizontal=TRUE)
vioplotW(dat6b, col="Spectral", halfViolin="pairwise", horizontal=FALSE)

wrGraph documentation built on Oct. 20, 2023, 5:08 p.m.