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).
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
)
This function plots a figure (to the current graphical device)
(matrix, list or data.frame) data to plot, or first series of data
(numeric) additional sets of data to plot
(logical) eliminate non-finite elements to avoid potential errors (eg when encountering NA
)
(logical) omit empty series (or less than 4 finite numeric entries) of data from plot
(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
(character) decide if boxplot should be adde inside the violin, use "def" for default transparent grey
(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
(NULL
or numeric, length=2) custom limit on x-axis, see also par
(NULL
or numeric, length=2) custom limit on y-axis, see also par
(character) custom label for data-sets or columns (length must match number of data-sets)
(numeric) size of individual data-series labels as cex-expansion factor (see also par
)
(logical) orientation of plot
(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
(character) custom color for figure border
(character) custom x-axis label
(character) custom y-axis label
(numeric) size of axis labels as cex-expansion factor (see also par
)
(numeric) size of numeric y-axis labels as cex-expansion factor (see also par
)
(integer) line-type for linear regression line (see also par
)
(character or numeric) display of median: color (defauly white)
(numeric) display of median : size of point as cex-expansion factor (see also par
)
(character) custom title to figure
(integer) orientation of axis labels (see also par
)
(integer) width of line(s) (see also par
)
(character) color of rectangle
(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
(logical) add to existing plot if TRUE
(integer) relative expansion factor of the violin
(logical) suppress messages
(logical) additional messages for debugging
(character) allow easier tracking of messages produced
The (relative) width of the density-profiles ('Violins') may be manually adjusted using the parameter wex
which applies to all profiles drawn.
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
the package vioplot, sm
is used for the density estimation
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)
Run the code above in your browser using DataLab