Difference between revisions of "Boxplot"

From Christoph's Personal Wiki
Jump to: navigation, search
(New page: In descriptive statistics, a '''boxplot''' (also known as a '''box-and-whisker diagram''' or '''plot''') is a convenient way of graphically depicting groups of numerical data through their...)
 
(External links)
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
  
 
This article will various practical ways of creating boxplots using the [[R programming language]].
 
This article will various practical ways of creating boxplots using the [[R programming language]].
 +
 +
==Filetypes==
 +
svg(file = "foo.svg", width = 2.5, height = 5, pointsize = 8)
 +
postscript("foo.ps", paper="special", height=6, width=6, horizontal=F)
 +
pdf("foo.pdf", height=6, width=6)
  
 
==Example-01==
 
==Example-01==
  data(morley)
+
data(morley)
  morley$Expt <- factor(morley$Expt)
+
morley$Expt <- factor(morley$Expt)
  morley$Run <- factor(morley$Run)
+
morley$Run <- factor(morley$Run)
  attach(morley)
+
attach(morley)
 
   
 
   
  postscript("Michelsonmorley-boxplot.ps", paper="special", height=6, width=6,
+
postscript("Michelsonmorley-boxplot.ps", paper="special", height=6, width=6,
            horizontal=F)
+
            horizontal=F)
  par(las=1)
+
par(las=1)
  par(mar=c(5.1, 5.1, 2.1, 2.1))
+
par(mar=c(5.1, 5.1, 2.1, 2.1))
  par(font=2)
+
par(font=2)
  par(font.axis=2)
+
par(font.axis=2)
  boxplot(Speed ~ Expt, xlab = "Experiment No.", ylab="Speed of light (km/s minus 299,000)")
+
boxplot(Speed ~ Expt, xlab = "Experiment No.", ylab="Speed of light (km/s minus 299,000)")
  abline(h=792.458, lty=3)
+
abline(h=792.458, lty=3)
  dev.off()
+
dev.off()
  
 
*Another way to do the same thing:
 
*Another way to do the same thing:
Line 33: Line 38:
 
==External links==
 
==External links==
 
*[[wikipedia:boxplot]]
 
*[[wikipedia:boxplot]]
 +
*[http://commons.wikimedia.org/wiki/Category:Created_with_R Collection of examples] &mdash; from Wikimedia Commons.
 
*[http://informationandvisualization.de/blog/box-plot Boxplot] &mdash; on the ''Information & Visualization'' blog
 
*[http://informationandvisualization.de/blog/box-plot Boxplot] &mdash; on the ''Information & Visualization'' blog
  
 
[[Category:Bioinformatics]]
 
[[Category:Bioinformatics]]
 
[[Category:Graphics software]]
 
[[Category:Graphics software]]

Latest revision as of 21:39, 18 February 2009

In descriptive statistics, a boxplot (also known as a box-and-whisker diagram or plot) is a convenient way of graphically depicting groups of numerical data through their five-number summaries (the smallest observation, lower quartile (Q1), median (Q2), upper quartile (Q3), and largest observation). A boxplot may also indicate which observations, if any, might be considered outliers.

This article will various practical ways of creating boxplots using the R programming language.

Filetypes

svg(file = "foo.svg", width = 2.5, height = 5, pointsize = 8)
postscript("foo.ps", paper="special", height=6, width=6, horizontal=F)
pdf("foo.pdf", height=6, width=6)

Example-01

data(morley)
morley$Expt <- factor(morley$Expt)
morley$Run <- factor(morley$Run)
attach(morley)

postscript("Michelsonmorley-boxplot.ps", paper="special", height=6, width=6,
           horizontal=F)
par(las=1)
par(mar=c(5.1, 5.1, 2.1, 2.1))
par(font=2)
par(font.axis=2)
boxplot(Speed ~ Expt, xlab = "Experiment No.", ylab="Speed of light (km/s minus 299,000)")
abline(h=792.458, lty=3)
dev.off()
  • Another way to do the same thing:
data(morley)
morley$Expt <- factor(morley$Expt)

pdf("Michelsonmorley-boxplot.pdf", height=6, width=6)
par(las=1, mar=c(5.1, 5.1, 2.1, 2.1))
boxplot(Speed ~ Expt, morley, xlab = "Experiment No.",
        ylab="Speed of light (km/s minus 299,000)")
abline(h=792.458, col="red")
text(3,792.458,"true\nspeed")
dev.off()

External links