Description Usage Arguments Details Value Methods (by class) See Also Examples
Produce violin (density) plots of the given (optionally grouped) values. Optionally add slender superimposed boxplots.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | violinplot(x, ...)
## S3 method for class 'matrix'
violinplot(x, ...)
## S3 method for class 'data.frame'
violinplot(x, ...)
## S3 method for class 'list'
violinplot(x, ...)
## S3 method for class 'formula'
violinplot(formula, data = NULL, ..., na.action = NULL,
drop.unused = FALSE)
## Default S3 method:
violinplot(x, ..., at = NULL, width = 1, names = NULL,
col = NULL, border = 1, groups = NULL, group.spacers = 1,
group.labels = NULL, group.lines = TRUE, density.auto = TRUE,
density.scale = TRUE, density.ticks = TRUE, density.args = NULL,
boxplot.args = TRUE, legend.args = NULL, grid.args = TRUE,
text.cex = 1, mar = FALSE, add = FALSE)
|
x |
for specifying data from which the violin plots (and
optionally boxplots) are to be produced. Either a numeric vector,
a single list containing such vectors, or a data.frame or matrix
(where columns are the vectors to be used). Additional unnamed
arguments specify further data as separate vectors (each
corresponding to a component violin plot with or without a
corresponding boxplot). |
... |
Unnamed arguments ('default' method only) are additional
data vectors; for all other methods, unnamed arguments are
ignored. Named arguments are passed through to the 'default'
method and optionally to |
formula |
a formula, such as |
data |
data.frame or list from which the variables in
|
na.action |
passed to |
drop.unused |
passed to |
at |
numeric vector giving the locations where the violin
plots should be drawn, particularly when |
width |
numeric, how wide the violin plot can extend where "1" means two neighboring plots may touch but not overlap; greater than 1 and overlap may occur, less than 1 and there will always be space between neighboring violin plots. |
names |
character vector of names to be printed under the
plots; if missing, the names will be derived from |
col |
if not |
border |
an optional vector of colors for the outlines of the
violin plots. As with |
groups |
for internal use only (calls between methods), a list for assigning groups and levels of the data. (Internally, the structure is a list of lists, where each element of the top-level list represents a grouping level. Each grouping-level list contains more lists, where each contains contiguous x positions for that group.) |
group.spacers |
numeric, the amount of space to be used for a spacing between groups, defaults to 1 (same width as an individual violin plot). When there are multiple levels ("formula" method), this vector has as many numbers as levels. |
group.labels |
if logical and |
group.lines |
if logical and |
density.auto |
logical, whether to auto-scale the density
curves to the maximum density of all curves, default |
density.scale |
if logical and |
density.ticks |
logical or integer, tick marks on each
grouping line (lowest level only). Default |
density.args |
list of arguments to pass to
|
boxplot.args |
list of arguments to pass to
|
legend.args |
list of arguments to pass to
|
grid.args |
list of arguments to pass to |
text.cex |
numeric, cex to use for group labels; the scale (if
|
mar |
if logical and |
add |
logical, create a new plot or add to the existing
device. Default is |
The generic function violinplot
currently has a default method
(violinplot.default
), several helper methods (for "list", "matrix",
and "data.frame"), and a "formula" interface (violinplot.formula
).
If multiple groups are supplied either as multiple arguments are via a formula, parallel violin plots will be plotted, in the order of the arguments or the order of the levels of the groups.
Missing values are ignored when forming violin plots.
list of various parameters, invisibly
matrix
: matrix method:
data.frame
: data.frame method:
list
: list method:
formula
: "formula" method
default
: default method:
density
which does much of the computation;
boxplot
for optional overlaid boxplots;
legend
; model.frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Not run:
# default method
violinplot(mtcars$mpg)
violinplot(mtcars$mpg, col = 2)
violinplot(mtcars$mpg, col = 4, boxplot.args = FALSE)
# matrix method
m <- matrix(runif(99), ncol = 3)
violinplot(m, col = 2:4)
violinplot(m, col = 2:4, width = 1.5)
# data.frame method
violinplot(mtcars[,1:4], col = 2:9) # extra colors are silently discarded
# list method
l <- list(x1 = runif(100), x2 = rnorm(200, mean = 1))
violinplot(l)
# formula method
violinplot(mpg ~ cyl, data = mtcars, col = 2:4)
violinplot(mpg ~ cyl, data = mtcars, col = 2:4,
legend.args = list(x = "bottomleft", bty = "n"))
violinplot(mpg ~ cyl + vs, data = mtcars, col = 2:4,
group.labels = 2)
violinplot(mpg ~ cyl + vs, data = mtcars, col = 2:4,
group.labels = 2, drop.unused = TRUE)
violinplot(~ ., data = mtcars) # same as violinplot(mtcars)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.