vioplotW {wrGraph} | R 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 |
removeEmpty |
(logical) omit empty series (or less than 4 finite numeric entries) of data from plot |
halfViolin |
(logical or character) decide with |
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 |
xlim |
( |
ylim |
( |
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 |
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 |
cexAxis |
(numeric) size of numeric y-axis labels as cex-expansion factor (see also |
lty |
(integer) line-type for linear regression line (see also |
pointCol |
(character or numeric) display of median: color (defauly white) |
cexPt |
(numeric) display of median : size of point as cex-expansion factor (see also |
tit |
(character) custom title to figure |
las |
(integer) orientation of axis labels (see also |
lwd |
(integer) width of line(s) (see also |
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 |
add |
(logical) add to existing plot if |
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)