s.e.roberts at qmul.ac.uk
2006-Mar-12 13:34 UTC
[R] Misalignment of secondary axis on boxplot
Dear R-help, I am trying to overlay a secondary y-axis over a boxplot. The problem is that the point of the line does not correspond to the centrepoint of the boxplot, which makes presentation and interpretation sloppy. Could someone point out where I am going wrong please? #DATA f<-factor(ld$Name[ld$Order==5],levels=c("SVR","MKF","DRCH","TNC","MTN","WLB","HMB")) g<-c(0.0213750, 0.0017000, 0.0228150, 0.0000000, 0.0787800,NA, 0.0220400, 0.0471900, 0.0060500, NA, 0.0285600, 0.0079980, 0.0000000,NA,0.0175560,0.0754110,NA, 0.0702780,NA, 0.0065875, 0.0000000, NA, 0.0000000, 0.0000000, 0.0723450, 0.0143520, 0.0000000, 0.1398600, 0.0032000, NA,NA,0.0500850,NA, 0.0038250, 0.0000000,0.0071250, 0.0394200, 0.0000000, 0.0000000,NA,0.0000000,NA, 0.0000000, 0.0246375, NA, NA, 0.0120750, 0.0076125,NA,NA,0.0153400, 0.0077000,NA) boxplot(g~f,ylab="",xlab="",main="") par(new=T) s.f<-c(0.5085714, 1.5777778, 0.6071429, 0.5233333, 0.5916667,1.1742857, 0.7987500) plot(s.f,main="",ylab="",xlab="",type="b",axes=F,pch=19) axis(4) Thanks in advance, Sion (R 2.1.1) -- Si?n Roberts Department of Geography, Queen Mary, University of London, London, E1 4NS. Tel: +44 20 7882 5400 http://www.geog.qmul.ac.uk/postgraduate/student/roberts.html
s.e.roberts at qmul.ac.uk wrote:> Dear R-help, > > I am trying to overlay a secondary y-axis over a boxplot. The problem is that > the point of the line does not correspond to the centrepoint of the boxplot, > which makes presentation and interpretation sloppy. Could someone point out > where I am going wrong please?1. We do not have the object "ld", hence we do not see anything ... 2. I guess you do not want to call lines() rather than plot() when adding elements to the boxplot .... Uwe Ligges> > #DATA > > f<-factor(ld$Name[ld$Order==5],levels=c("SVR","MKF","DRCH","TNC","MTN","WLB","HMB")) > > g<-c(0.0213750, 0.0017000, 0.0228150, 0.0000000, 0.0787800,NA, 0.0220400, > 0.0471900, 0.0060500, NA, 0.0285600, 0.0079980, > 0.0000000,NA,0.0175560,0.0754110,NA, 0.0702780,NA, 0.0065875, 0.0000000, NA, > 0.0000000, 0.0000000, 0.0723450, 0.0143520, 0.0000000, 0.1398600, 0.0032000, > NA,NA,0.0500850,NA, 0.0038250, 0.0000000,0.0071250, 0.0394200, 0.0000000, > 0.0000000,NA,0.0000000,NA, 0.0000000, 0.0246375, NA, NA, 0.0120750, > 0.0076125,NA,NA,0.0153400, 0.0077000,NA) > > boxplot(g~f,ylab="",xlab="",main="") > par(new=T) > s.f<-c(0.5085714, 1.5777778, 0.6071429, 0.5233333, 0.5916667,1.1742857, > 0.7987500) > plot(s.f,main="",ylab="",xlab="",type="b",axes=F,pch=19) > axis(4) > > Thanks in advance, > Sion > > (R 2.1.1) > > -- > Si?n Roberts > > Department of Geography, > Queen Mary, University of London, > London, > E1 4NS. > > Tel: +44 20 7882 5400 > http://www.geog.qmul.ac.uk/postgraduate/student/roberts.html > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html