
Last chance! 50% off unlimited learning
Sale ends in
PlotViolin(x, ...)
"PlotViolin"(x, ..., horizontal = FALSE, bw = "SJ", na.rm = FALSE, names = NULL, args.boxplot = NULL)
"PlotViolin"(formula, data, subset, na.action, ...)
FALSE
means vertical arrangement.density
.
bw
can also be a character string giving a rule to choose the bandwidth. See bw.nrd
.
The default, has been switched from "nrd0"
to "SJ"
, following the general recommendation in Venables & Ripley (2002).
In case of a method, the average computed bandwidth is used.FALSE
.getOption("na.action")
.polygon
. Notably, you can set the color to red with col="red"
, and a border color with border="blue"
NA
to suppress the boxplot.out
whose elements
indicate to which group the outlier belongs.boxplot
, PlotMultiDens
, density
# make a "violin"
x <- c(rnorm(100), rnorm(50,5))
PlotViolin(x, col = "brown")
par(mfrow=c(1,2))
f <- factor(rep(1:5, 30))
# make a quintet. Note also choice of bandwidth
PlotViolin(x ~ f, col = SetAlpha("steelblue",0.3), bw = "SJ", main="Vertical")
# and the same, but in horizontal arrangement
PlotViolin(x ~ f, col = SetAlpha("steelblue",0.3), bw = "SJ", horizontal = TRUE,
las=1, main="Horizontal")
# example taken from boxplot
boxplot(count ~ spray, data = InsectSprays, col = "lightgray", main="Boxplot")
PlotViolin(count ~ spray, data = InsectSprays, col = "lightgray", main="Violinplot")
# groupwise densityplots defined the same way as in boxplot
boxplot(len ~ supp*dose, data = ToothGrowth,
main = "Guinea Pigs' Tooth Growth",
xlab = "Vitamin C dose mg", ylab = "tooth length",
col=c("yellow", "orange"), lty=c(1,2)
)
b <- PlotViolin(len ~ supp*dose, data = ToothGrowth,
main = "Guinea Pigs' Tooth Growth",
xlab = "Vitamin C dose mg", ylab = "tooth length",
col=c("yellow", "orange"), lty=c(1,2)
)
# use points, if the medians deserve special attention
points(x=1:6, y=b$stats[3,], pch=21, bg="white", col="black", cex=1.2)
Run the code above in your browser using DataLab