Create beanplots as alternative to boxplots. requires package *beanplot*. A discussion on differences between boxplots and violin plots to beanplots is given *here*. This post was inspired by *this* paper whose authors posted their code *here*. The distribution mean is visualized by a long black line. Standard deviation and median are visualized by green and red short lines, respectively.

beanplotter <- function(dataframe, outname, yname, maxval = Inf){ require(beanplot) pdf(file = outname, width=2*ncol(dataframe), height = 5) par(mar = c(2,3,1,1)) #bottom, left, top, right par(mgp = c(1.5,0.5,0)) #axlabeldist,ticklabeldist,axdist beanplot::beanplot(dataframe, main = "",xlab = "", ylab = yname, axes = F, log = "", cex = 2.5, cutmax = maxval) for(j in 1:ncol(dataframe)) { start <- .95 + (j-1) median <- median(dataframe[,j]) sdev <- sd(dataframe[,j]) mean <- mean(dataframe[,j]) segments(start, median, (start+.1), median, col = "red", lwd=3) segments(start, mean-sdev, (start+.1), mean-sdev, col = "green", lwd=3) segments(start, mean+sdev, (start+.1), mean+sdev, col = "green", lwd=3) } axis(1, at = 1:ncol(dataframe), labels = names(dataframe), cex = 2.5) axis(2, ylab = yname, cex = 2.5) box() dev.off() }

Example:

d <- data.frame(rnorm(mean = 1.6, 50), rnorm(mean = 1.6, 50), rnorm(mean = 1.6, 50)) names(d) <- c("one","two","three") outname <- "E:/beanplot.pdf" beanplotter(d, outname, yname = "values")