
Displays violin plots (rotated kernel density plots on each side of boxplots).
violin_plot(X=rnorm(50),at,add=FALSE,na.rm=TRUE,bw,violin_width,
violin_end_width=0.005,equal_width=TRUE,show_box=TRUE,box_width=0.01,
box_col="black",show_outliers=TRUE,outlier_pch=NA,range=1.5,xlim,ylim,
axes=TRUE,ann=TRUE,xlab="",ylab="",x_axis_labels,main="Violin Plot",
col="red",median_col="white",show_mean=FALSE,mean_pch=19,
mean_pch_col="yellow",...)
nil
A vector or matrix or data frame of numeric values.
Horizontal position(s) for the violin plot(s).
Whether this violin should be added to an existing plot.
Remove NA values. Passed to functions such as boxplot or density.
Vector or bandwidth values for density. Will be recycled. If not provided then will be calculated using bw.nrd0.
Multiplier to scale the width of the violin.
Multiplier to scale the width of the ends of the violin.
Should all violin widths be equal?
Whether to display the box.
Multiplier for the width of internal boxes.
Fill color for the internal rectangle.
Whther to display outliers as points.
Symbol for displaying outliers.
Passed to boxplot.
Explicitly set the plot limits.
Logical value indicating whether both axes should be drawn on the plot.
Annotate the plots with axis titles and overall titles.
Labels for the X and Y axes.
Labels for the violins.
Title for the violin plot.
Fill color for the violin(s). Will be recycled.
Fill color for the median mark.
Whether to plot the mean as well as the median.
Symbol to use for the mean.
Fill color for the mean symbol.
Extra arguments passed to polygon used for representing violin(s).
Darshan Baral
violin_plot displays one or more violin plots by drawing rotated kernel density curves on each side of box plots.
# plotting a data frame
violin_plot(mtcars)
set.seed(42)
normvar<-c(rnorm(49),-3)
unifvar<-runif(50,-2,2)
normvar2<-rnorm(45)
# plotting a matrix
violin_plot(matrix(c(normvar,unifvar),ncol=2),
main="Default Plot",x_axis_labels=c("Normal","Uniform"))
# plotting with different colors and with at specified
violin_plot(matrix(c(normvar,unifvar),ncol=2),at=1:3,
main="Different colors and extra space",
x_axis_labels=c("Normal","Uniform","Normal"),
show_outliers=TRUE,col=c("blue","red"),median_col="lightgray",
pch=6)
# adding a violin to existing plot
violin_plot(normvar2,at=3,add=TRUE,col="green",violin_width=1)
Run the code above in your browser using DataLab