Learn R Programming

caroline (version 0.5.0)

volins: Plot a Series of Vioplot Violins

Description

This is an improvment on the original vioplot function (combination of a box plot and a kernel density plot). You can now pass a list of violins and a list of colors. Optionally it also returns statistics on the distributions as well.

Usage

violins(x, by, range = 1.5, h = NULL, ylim = NULL, names =
                 NULL, horizontal = FALSE, col = "transparent", border
                 = "black", lty = 1, lwd = 1, rectCol = "grey50",
                 colMed = "grey80", pchMed = 19, at, add = FALSE, wex =
                 1, drawRect = TRUE, main = "", connect = TRUE, 
                 connect.col='lightgreen', connect.lty=1, connect.lwd=1,
                 xlab='', ylab='', stats=FALSE, ci.median_mu = TRUE)

Arguments

x
list of vectors or a dataframe
by
accepts 'by' object for grouping
range
a factor to calculate the upper/lower adjacent values.
h
the height for the density estimator, if omit as explained in sm.density, h will be set to an optimum.
ylim
y limits.
names
one label, or a vector of labels for the datas must match the number of datas given.
horizontal
description of var 1.
col,border,lty,lwd
Graphical parameters for the violin passed to lines and polygon.
rectCol,colMed,pchMed
Graphical parameters to control the look of the box.
at
position of each violin. Default to 1:n
add
logical. if FALSE (default) a new plot is created
wex
relative expansion of the violin.
drawRect
logical. the box is drawn if TRUE.
main
main title for the plot.
connect
connects a violin plot series at the medians with line segments
connect.col
line color of the median connecting line segments
connect.lty
line type of the median connecting line segments
connect.lwd
line width of the median connecting line segments
xlab
x axis label
ylab
y axis label
stats
print out statistics
ci.median_mu
boolean for 95 pct ci.median and huber.mu M-estimator calculations

Value

  • a series of violin plots

See Also

vioplot

Examples

Run this code
n <- rnorm(130, 10, 3)
p <- rpois(110, 4)
u <- runif(300, 0, 20)
l <- rlnorm(130, log(2))
g <- rgamma(140, 3)
e <- rexp(160)

violins(list(e=e, p=p,u=u,n=n,l=l,g=g), ylim=c(0,20),
         col=c('purple','lightblue','lightgreen','red','orange','yellow'),
         stats=TRUE)

Run the code above in your browser using DataLab