#title Boxplot [[TableOfContents]] ==== shape ==== {{{ library(rgr) shape(iris$Sepal.Length, ifqs = TRUE) }}} attachment:4-plot/shape.png ==== boxplot + scatter ==== --http://www.ats.ucla.edu/stat/r/dae/ologit.htm {{{ dat <- read.dta("http://www.ats.ucla.edu/stat/data/ologit.dta") ggplot(dat, aes(x = apply, y = gpa)) + geom_boxplot(size = .75) + geom_jitter(alpha = .5) + facet_grid(pared ~ public, margins = TRUE) + theme(axis.text.x = element_text(angle = 45, hjust = 1, vjust = 1)) }}} ==== boxplot + errorbar + label ==== {{{ library(MKmisc) rb <- qboxplot(Sepal.Length ~ Species, data=iris, col="bisque") title("Comparing boxplot()s and non-robust mean +/- SD") mn.t <- tapply(iris$Sepal.Length, iris$Species, mean) sd.t <- tapply(iris$Sepal.Length, iris$Species, sd) xi <- 0.3 + seq(rb$n) points(xi, mn.t, col = "orange", pch = 18) arrows(xi, mn.t - sd.t, xi, mn.t + sd.t, code = 3, col = "pink", angle = 75, length = .1) for(i in 1:length(rb$names)){ #text(i, rb$stats[,i], labels=rb$stats[,i], cex=0.7, pos=3) text(i, rb$stats[2:4,i], labels=rb$stats[2:4,i], cex=0.7, pos=3) } }}} attachment:Boxplot/boxplot_errorbar.png ==== boxplot + point ==== {{{ source("https://bioconductor.org/biocLite.R") biocLite("genefu") library(genefu) dd <- list("G1"=iris[iris$Species =="setosa", 1], "G2"=iris[iris$Species =="versicolor", 1], "G3"=iris[iris$Species =="virginica", 1]) boxplotplus2(x=dd) }}} attachment:Boxplot/boxplotplus2.png {{{ install.packages("LSD") library(LSD) dd <- list("G1"=iris[iris$Species =="setosa", 1], "G2"=iris[iris$Species =="versicolor", 1], "G3"=iris[iris$Species =="virginica", 1]) linesplot(dd,alpha=25,border="darkred",addboxes = TRUE,outline=FALSE) }}} attachment:Boxplot/linesplot.png ==== pirateplot ==== http://www.r-bloggers.com/the-pirate-plot-2-0-the-rdi-plotting-choice-of-r-pirates/ Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from http://www.sourceforge.net/projects/mcmc-jags/files {{{ install.packages("devtools") library("devtools") install_github("ndphillips/yarrr") library("yarrr") #http://www.sourceforge.net/projects/mcmc-jags/files par(mfrow=c(2,2)) pirateplot(formula = age ~ favorite.pirate, data = pirates, xlab = "Favorite Pirate", ylab = "Age", main = "My First Pirate Plot!") pirateplot(formula = age ~ favorite.pirate, data = pirates, xlab = "Favorite Pirate", ylab = "Age", main = "Black and White Pirate Plot", pal = "black", hdi.o = .7, line.o = 1, bar.o = .1, bean.o = .1, point.o = .1, point.pch = 16, back.col = gray(.97)) pirateplot(formula = age ~ favorite.pirate, data = pirates, xlab = "Favorite Pirate", ylab = "Age", main = "Black and White Pirate Plot", pal = "black", hdi.o = 0, line.o = 0, bar.o = 1, bean.o = 0, point.o = 0) pirateplot(formula = beard.length ~ sex + college, data = pirates, main = "Beard lengths", pal = "southpark", xlab = "", ylab = "Beard Length", point.pch = 16, point.o = .2, hdi.o = .6, bar.o = .1, line.o = .5) par(mfrow=c(1,1)) }}} attachment:Boxplot/pirateplot.png