Here are 3 approaches: barplot( 1:12, xlim=c(0,12), width=1, space=0, names.arg=substr(month.abb,1,1)) lines( (1:12) - 0.5, 1:12, type='b', lwd=2, col='red' )
### or tmp <- barplot(1:12, names.arg=substr(month.abb, 1,1)) lines( tmp, 1:12, type='b', lwd=2, col='red' ) ### or library(TeachingDemos) tmp <- barplot(1:12, names.arg=substr(month.abb, 1,1)) updateusr( tmp[1:2], 0:1, 1:2, 0:1 ) lines( 1:12, 1:12, type='b', lwd=2, col='red' ) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: Steve Murray [mailto:smurray...@hotmail.com] > Sent: Monday, June 15, 2009 3:03 PM > To: Greg Snow; r-help@r-project.org > Subject: RE: [R] Aligning axis values when plotting more than one graph > on same axes > > > Thanks for the replies. > > This is a simple example which demonstrates exactly the problems I'm > facing. As you can see, neither the x or y axes line up consistantly. > > > barplot(1:12, names.arg=substr(month.abb, 1,1)) > > par(new=TRUE) > > plot(1:12, 1:12, type="b", lwd=2, col="red", xaxt="n") > > > I'd be surprised if there isn't a solution to this, seeing as they're > two essential graph types in the base package? > > Any pointers would be most welcome! > > Thanks again, > > Steve > > > _________________________________________________________________ > Get the best of MSN on your mobile > http://clk.atdmt.com/UKM/go/147991039/direct/01/ ______________________________________________ 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.