Many thanks, it works beautifully! I'd not caught the use of colMeans() as the path to useable x-coordinates, and was fixated on the existing bargraph's x-vector for this purpose.
Ref your Q, I guess I had the lattice reference in there as a vestige of other attempts to get the job done with barchart i/o barplot. Galen -----Original Message----- From: Peter Ehlers [mailto:ehl...@ucalgary.ca] Sent: Friday, June 03, 2011 02:45 To: galen.a.mo...@gmail.com Cc: r-help@r-project.org Subject: Re: [R] Adding a line to a beside=TRUE barplot On 2011-06-02 13:09, Galen Moore wrote: > Greetings > > > > Grateful for any help on this one: > > > > In the following demo code, I am trying to get the points in the line > to appear over the same x-axis labels as are used by the paired Bars. > It appears, however, that R/lattice ignores the x-axis points used by > the bars and plots the x points for the line at ½ points. > > > > Can you help me tweak this code so that the nth bump in the line > appears over the same nth pair of bars? Im open to any options > besides lattice/barplot. > > > > library(lattice) > > aa<- abs(rnorm(c(1:10)))*5 > > bb<- abs(rnorm(c(1:10)))*5 > > cc<- abs(rnorm(c(1:10)))*5 > > > > dd<- as.matrix(cbind(aa, bb)) > > > > barplot(t(dd), beside=TRUE, ylim=c(0,10)) > > lines(cc) What's lattice doing here? barplot() is not a lattice function. Careful reading of the help page for barplot and study of the examples will lead you to: mp <- barplot(t(dd), beside=TRUE) mp lines(colMeans(mp), cc, col=2, lwd=3) Peter Ehlers > > > > Many thanks, > > > > Galen > > > [[alternative HTML version deleted]] > ______________________________________________ R-help@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.