[R] Adding horizontal lines to Boxplot

Frede Aakmann Tøgersen FredeA.Togersen at agrsci.dk
Fri Oct 19 11:55:43 CEST 2007

If you carefully read the man for boxplot (?boxplot) you can see in the examples that you can put in a ylim as an argument to the boxplot function:
boxplot(3:5, 2:4,4:6, ylim = c(0, 8))

See also ?bxp.

best regards




Fra: Klaus Friis Østergaard [mailto:farremosen at gmail.com]
Sendt: fr 19-10-2007 11:24
Til: Frede Aakmann Tøgersen
Cc: Gabor Grothendieck; r-help at r-project.org
Emne: Re: [R] Adding horizontal lines to Boxplot

2007/10/19, Frede Aakmann Tøgersen <FredeA.Togersen at agrsci.dk>: 

	So where is the reproducable example?
	How can we know that you're not doing
	abline(h = 400, col = "red")?
	best regards

You are right, a  reproducable example  should have been there. 

I don't know what I mistyped but  I got to work and here is an example that works,

boxplot(3.2:5.2, 1.9:3.9,3.9:5.9)
abline(h = 4)
abline(h = 2.5, col = "green")
abline(h = 2, col = "red") 
abline(h = 5.5, col = "green")
abline(h = 6, col = "red")

I also tested with the lwd parameter of the abline

 boxplot(3:5, 2:4,4:6)
 abline(h = 4)
 abline(h = 2.5, col = "red", lwd = 2)
 abline(h = 5.5, col = "red", lwd = 2)

Is it possible to scale the size of the boxplot, so that scale on the Y axis is say from 0 to 8 instead of 2 to 6 as it is in the example from above.

Klaus F. Østergaard, <farremosen(at)gmail dot com> 

More information about the R-help mailing list