[R] abline plots at wrong abscissae after boxplot

S Ellison S.Ellison at lgc.co.uk
Fri Jun 22 13:49:38 CEST 2007


Boxplot positions and labels are not the same thing.
You have groups 'called' "2", "3", "4". As factors - which is what bocplot will turn them into -  they will be treated as arbitrary labels and _numbered_ 1:3 (try as.numeric(factor(x)). 

So your lm() used 2:4, but your plot (and abline) uses 1:3 for positions and "2" - "4" as labels. 

The best option used to be to plot the boxes at positions 2:4. Look at the at= parameter in boxplot.
But that is now of little help because there is no way of overriding xlim, leaving you no alternative but to reformulate your model with an offset or something. 

I will take up the boxplot xlim issue separately on R-dev; it's not the only such.

Steve Ellison.

>>> "Brian Wilfley" <bwilfley at tripleringtech.com> 21/06/2007 22:44:17 >>>
I'm trying to add lines to a plot originally made with "boxplot", but
the lines appear in the wrong place. 

*******************************************************************
This email and any attachments are confidential. Any use, co...{{dropped}}



More information about the R-help mailing list