[R] Two y-axes boxplot

From: stephen sefick <ssefick_at_gmail.com>
Date: Mon, 09 Jun 2008 10:51:55 -0400


I am aware of the inherent risks of having plots with more than two axes, but I am trying to produce the graphs that I have been tasked with. That being said I am having a hard time figuring out how to have two axes onto a boxplot. below is the sample code. I would like BC on the plot produced with this code to be on a second axis with all of the others being on the first axis. This will be used in a layout 4 rows by two columns with this being the only one with two axes. Any help would be greatly appreciated.

Stephen

order <- factor(as.character(x$Site),

                              levels=c("Betty's Branch", "Stevens Creek",

"North Augusta", "520", "Horse Creek", "Stan's", "Butler
Creek","Downstream", "IP", "Vogtle", "301", "Clyo"))

#Chloride

d <- boxplot(Chloride~order, data=x, main="Chloride", ylab="mg/L", names=c("215",
"SC", "202", "198", "HC", "190", "BC", "185", "179", "148", "119", "61"))

mtext(paste("(n=", d$n, ")", sep = ""), at = seq_along(d$n), line = 2, side = 1, cex=0.66)

#data

x <- (structure(list(Site = structure(c(3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 11L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
9L, 9L, 9L, 9L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 7L, 7L, 7L, 7L, 7L,
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L,
6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L,
8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L, 12L,
12L, 12L, 12L, 12L, 12L, 12L, 12L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("301",

"520", "Betty's Branch", "Butler Creek", "Clyo", "Downstream",
"Horse Creek", "IP", "North Augusta", "Stan's", "Stevens Creek",

"Vogtle"), class = "factor"), Chloride = c(3, 2.6, 2.5, 2.4,
2.5, 2.3, 2.5, 3, 2.6, 2.6, 2.6, 2.9, 2.8, 2.7, 3, 2.8, 2.7,
2.7, 2.7, 2.7, 2.8, 2.7, 2.7, 3.5, 7.3, 7.2, 5.2, 5.8, 4.7, 6.3,
6.7, 13, 5.3, 6.3, 5.8, 5.2, 6.9, 6.3, 6.5, 4.2, 4.6, 3.8, 4.6,
4.1, 4.8, 7.3, 2.9, 2.6, 3.4, 2.5, 2.5, 2.4, 2.7, 3, 2.8, 2.8,
3.2, 3.1, 2.9, 3, 3.1, 2.9, 2.8, 2.8, 2.8, 2.8, 2.9, 2.9, 3.1,
2.9, 2.7, 2.6, 2.6, 2.7, 2.4, 2.6, 2.7, 2.8, 2.9, 3.2, 3, 3,
3, 3.4, 2.9, 2.8, 2.8, 2.8, 2.8, 3, 3, 3.1, 2.8, 2.8, 2.7, 2.8,
3.3, 2.6, 2.8, 3.6, 3, 3, 3, 3.3, 2.9, 2.8, 2.9, 2.8, 2.7, 2.8,
2.8, 2.8, 2.9, 2.9, 3.1, 2.8, 3.4, 2.9, 2.8, 2.9, 2.6, 3, 2.9,
3.8, 3.5, 3.2, 3.4, 3.5, 3.8, 3.6, 3.2, 3.2, 3.4, 3.2, 3.4, 4.4,
33, 100, 150, 92, 150, 150, 97, 190, 95, 160, 54, 95, 87, 160,
160, 46, 180, 120, 160, 130, 150, 68, 3.8, 5.4, 5.6, 4.3, 4.7,
6.1, 6.2, 5.6, 6.5, 5.4, 5.1, 5.2, 8.3, 4.7, 5, 3.4, 4.7, 5.8,
6.2, 5.7, 6.8, 5.4, 10, 7.5, 5.2, 8.1, 7.4, 13, 10, 12, 7.8,
6.4, 7.3, 17, 6.4, 7.2, 7.1, 11, 8.4, 8.9, 8.2, 10, 4.7, 8.7, 8.5, 7.2, 7.5, 5.6, 12, 10, 10, 12, 8.6, 6.2, 6.8, 14, 6, 6.9, 7, 9, 8.4, 8.8, 8.4, 9.6, 8.8, 7.8, 13, 10, 11, 12, 7.8, 7.4, 8.1, 12, 7.4, 9.2, 8.5, 8.8, 10, 10, 11, 9.4, 12, 10, 11, 13, 8.6, 7, 6.9, 12, 8.4, 11, 9.8, 10, 10, 11, 11, 9.8)), .Names = c("Site",
"Chloride"), class = "data.frame", row.names = c(NA, -256L)))
-- 
Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.

-K. Mullis

	[[alternative HTML version deleted]]

______________________________________________
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.
Received on Mon 09 Jun 2008 - 15:06:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 09 Jun 2008 - 15:30:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive