Description Usage Arguments Details Value Author(s) References See Also Examples
viopoints draws one dimensional scatter plots with jitter using kernel
density estimates. The plots are similar to stripchart
when the sample size is small. If the sample size is large, the plots are
similar to violin plots.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | viopoints(x, ...)
## S3 method for class 'formula'
viopoints(formula, data = NULL, ..., subset, na.action = NULL)
## Default S3 method:
viopoints(x, ..., groups, na.group = FALSE,
method = "violin", side = "both", amount = jitter,
jitter = 0.2, offset = 1, density.par = list(na.rm = TRUE),
horizontal = !vertical, vertical = TRUE, at, points = TRUE,
pch = par("pch"), cex = par("cex"), col = "red", bg = "pink",
lines = FALSE, line.lty = par("lty"), line.lwd = 0.5,
line.col = "lightgray", add = FALSE, axes = TRUE,
frame.plot = axes, axis.par, group.names, main = "", sub = "",
xlab, ylab, dlab = "", glab = "", xlim, ylim, log = "")
|
formula |
a formula, such as |
data |
a data frame (or list) from which the variables in
|
... |
For the formula method, further arguments to be passed to the default method. For the default method, additional data. |
subset |
an optional vector specifying a subset of observations to be used for plotting. |
na.action |
a function which indicates what should happen when the data contain NAs. The default is to ignore missing values in either the response or the group. |
x |
data, either a numeric vector, matrix or data frame (list). |
groups |
grouping variable (usually a factor). |
na.group |
logical, if false (the default) drop an 'NA' level
from |
method |
the method to be used to separate coincident points.
The points are jitterd using kernel density estimates
if |
amount, jitter |
the amount of jitter when the method |
offset |
when the method |
density.par |
list of arguments passed to |
horizontal, vertical |
logical. If |
at |
a numeric vector giving the locations where component plots
should be drawn; defaults to |
side |
the side on which the points are plotted, one of |
points |
logical, if true (the default) draw points. |
pch, cex, col, bg |
graphical parameters passed to
|
lines |
logical, if true draw lines in a similar way to
parallel coordinates plots, defaults to |
line.lty, line.lwd, line.col |
the line type, width and color
for lines, passed to |
add |
logical, if true add points or lines to current plot,
defaults to |
axes |
logical, whether to plot axes; defaults to |
frame.plot |
logical, indicating if a frame ( |
axis.par |
list of arguments passed to |
group.names |
labels for the group axis. |
main, sub, xlab, ylab |
character strings for annotation,
passed to |
dlab, glab |
an alternative way to specify axis labels: see Details below. |
xlim, ylim |
numeric vectors of length 2, giving the range for the plot,
passed to |
log |
a character string, indicating if any axis should be drawn
in log scale, passed to |
The number of components k is the product of the number of (column)
vectors n and the number of levels of group m.
Arguments at and side are recycled to the length k.
Graphical parameters pch, cex, col, bg,
line.lty, line.lwd, line.col are recycled as follows.
If the length of a parameter is greater than m,
the parameter is recycled to the length k.
Otherwise the parameter is recycled to the length m first,
then each element of the parameter is repeated n times.
The dlab and glab labels may be used instead of xlab
and ylab if those are not specified. dlab applies to the
continuous data axis (the y axis if horizontal=FALSE or
vertical=TRUE), glab to the group axis.
If add=TRUE, arguments axes, frame.plot,
axis.par, group.names, main, sub,
xlab, ylab, dlab, glab,
xlim, ylim, log will be ignored.
Points are drawn after lines so that lines do not hide points.
An invisible numeric vector, giving the coordinates of the center of each component on the group axis.
Yuki Atoh yuki.atoh@gmail.com
Hintze, J. L. and Nelson, R. D. (1998). Violin plots: a box plot-density trace synergism. The American Statistician, 52(2):181-184.
boxplot, stripchart, density,
vioplot in package vioplot,
beanplot in package beanplot,
beeswarm in package beeswarm,
parviol in package parviol
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 | op <- par(mfrow=c(2,2))
gn <- c("SL", "SW", "PL", "PW")
for (i in c("overplot", "stack", "jitter", "violin"))
viopoints(iris[1:4], method=i, horizontal=TRUE, col=2:5, group.names=gn,
main=i)
par(op)
boxplot(Sepal.Length ~ Species, data=iris, ylab="Sepal.Length")
viopoints(Sepal.Length ~ Species, data=iris, col=2:4, add=TRUE)
boxplot(iris[1:4])
viopoints(iris[1:4], groups=iris[5], col=2:4, at=1:4+rep(c(-0.2,0,0.2),each=4),
jitter=0.1, add=TRUE)
legend("topright", legend=levels(factor(iris[,5])), pch=1, col=2:4)
boxplot(iris[1:4])
viopoints(as.matrix(iris[1:4])~iris[,5], col=2:4, at=1:4,
lines=TRUE, line.col=c("pink", "lightgreen", "skyblue"), add=TRUE)
legend("topright", legend=levels(factor(iris[,5])), pch=1, col=2:4)
viopoints(iris[c(1,3)], groups=iris[5], method="stack", amount=NA,
at=rep(1:3,each=2), pch=rep(1:2,3), side=c("n","p"), col=rep(2:3,3),
group.names=levels(factor(iris[,5])), main="stack")
legend("topleft", pch=1:2, col=2:3, legend=colnames(iris[c(1,3)]))
## Not run:
viopoints(as.matrix(iris[1:4]) ~ Species, data=iris, jitter=0.3, col=2:4,
axis.par=list(at=1:12, labels=paste(rep(substr(levels(factor(iris[,5])),1,3),
each=4), c("SL","SW","PL","PW"), sep="."), cex.axis=0.8, las=3))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.