plotrix (version 3.6-5)

violin_plot: Display a violin plot

Description

Displays violin plot(s)

Usage

violin_plot(X = rnorm(50), at, add=FALSE, na.rm = TRUE, bw = 0.35,
  violin_width = 1, violin_end_width = 0.005, equal_width = FALSE,
  box_width = 0.03, box_col = "black", show_outliers = FALSE, pch = 1,
  range = 1.5, xlim, ylim, xlab = "", ylab = "", x_axis_labels,
  main = "Violin Plot", col = "red", median_col = "white", plot_mean = FALSE,
  mean_pch = 19, mean_pch_col = "yellow", ...)

Arguments

X

A vector or matrix or data frame of numeric values.

at

Horizontal position(s) for the violins.

add

Whether this violin should be added to an existing plot.

na.rm

Remove NA values. Passed to functions such as boxplot.

bw

Bandwidth value for density.

violin_width

Multiplier to scale the widths of the violins.

violin_end_width

Multiplier to scale the width of the ends of the violins.

equal_width

Should all violin widths be equal?

box_width

Multiplier for the width of internal boxes.

box_col

Fill color for the internal rectangle.

show_outliers

Whether to display outliers as points.

pch

Symbol for displaying outliers.

range

Argument for boxplot.

xlim,ylim

Explicitly set the plot limits.

xlab,ylab

Axis labels.

x_axis_labels

Labels for the violins.

main

Title for the plot,

col

Fill color for the violins. Will be recycled.

median_col

Fill color for the median mark.

plot_mean

Whether to plot the mean as well as the median.

mean_pch

Symbol to use for the mean mark.

mean_pch_col

Fill color for the mean mark.

...

Extra arguments passed to polygon.

Value

nil

Details

violin_plot displays one or more violin plots by drawing the rotated kernel density on each side of the boxes.

Examples

Run this code
# NOT RUN {
 normvar<-c(rnorm(49),-4)
 unifvar<-runif(50,-2,2)

 violin_plot(matrix(c(normvar,unifvar),ncol=2),
  main="Default plot",x_axis_labels=c("Normal","Uniform"))

 violin_plot(matrix(c(normvar,unifvar),ncol=2),at=1:3,
  main="Different colors and extra space",
  x_axis_labels=c("Normal","Uniform","Normal"))

 normvar2<-rnorm(45)

 violin_plot(normvar2,at=3,add=TRUE,col="green")
# }

Run the code above in your browser using DataCamp Workspace