[R] Order of boxs in box plots

David Winsemius dwinsemius at comcast.net
Tue Oct 28 02:36:49 CET 2014


On Oct 27, 2014, at 6:10 PM, David Doyle wrote:

> Hello,
> 
> I'm doing some box plots to look at the distributions of groundwater
> results. It is plotting the well in the order of their IDs.  ie. MW1B then
> MW3B then MW4A.....
> 
> I would like to plot the wells in the order they are at the site such as MW1B
> then WES-14-4-93 then ........  Is there a way I can control that??
> 
> My data and code are below.
> 
> Thank you for your time
> David Doyle
> 
> 
> MS <- read.table("http://www.doylesdartden.com/R/MS.csv", header=TRUE,
> sep=",",)
> MSAmmoniax <- c("Well", "AMMONIA")
> MSAmmonia <- MS[MSAmmoniax]
> 

Pretty much all plotting routines (base, lattice, gpplot2)  use the levels as the ordering principle:

levels(MSAmmonia$Well) <- levels(MSAmmonia$Well)[c(1,6,2:5)]


> plot(MSAmmonia, notch=TRUE, ylab = "Ammonia (mg/L)", cex =
> 1,col=(c("green","White","White","white","white","green")))
> legend("topleft", inset=.002, title="Gradient",
>       c("Up","Down"), fill=terrain.colors(2), horiz=TRUE, cex = 0.7,)
> title(main="Lower Mudstone Ammonia Box Plots")


> 	[[alternative HTML version deleted]]
> 
You should learn to post in plain text.

> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list