Hi, Would you pls try these? x1<-c(1,2,10) x2<-c(-3,5,-8) barplot(x1,col="white",border="red",ylim=range(c(x1,x2))) barplot(x2,col="white",border="green",ylim=range(c(x1,x2)),add=T) axis(1, 0:3) box()
Q1, on x-axis "1,2,3" is not shown at the middle position of the bars. e.gfor first bar, "1" is tend to right ; while third bar, "3" is tend to left. Q2, once >box(), then bars are cut again. Q3, when y-axis is "0", I want to draw a parallel line to x-axis: I tried >lines(c(0,5),c(0,0)) ; is there any other way to do it? Thanks. Nina On 2/24/06, Romain Francois <[EMAIL PROTECTED]> wrote: > > Le 24.02.2006 11:17, jia ding a écrit : > > Thanks All! > > > > I combine your answers and post the code here again, if later somebody > need > > it. > > > > Actually, what I want is: > > > >> x1 > >> > > [1] 1 2 10 > > > >> x2 > >> > > [1] -3 5 -8 > > > >> barplot(x1,col="white",border="red") > >> barplot(x2,col="white",border="green",add=T) > >> > > So that, the two plots even share the same x-axis. > > > > But, It comes another question: > > > barplot(x2,col="white",border="green",add=T), because there are 2 > numbers > > are negative, some part of the bar is missing. Is there any automatic > > function to make the axes fit very well for both bars? > > > > > R> barplot(x1,col="white",border="red", ylim=range(c(x1,x2))) > > And, suppose I want to add another command: axis(1, 0:20) to draw > x-axis. I > > notice it increase like: 0,1,2,3,...20; how can I make it 0,5,15,20? > > > > > before doing axis(1, 0:20) have you tried to do > R> 0:20 > > So, > > R> axis(1, (0:4)*5) > or > R> axis(1, c(0,5, 10, 15, 20)) > or > R> axis(1, seq(0,20, by=5)) > > it's up to you. There are probably other solutions as well > > Thanks! > > > > > You're welcome > > Romain > > -- > visit the R Graph Gallery : http://addictedtor.free.fr/graphiques > Discover the R Movies Gallery : http://addictedtor.free.fr/movies > +---------------------------------------------------------------+ > | Romain FRANCOIS - http://francoisromain.free.fr | > | Doctorant INRIA Futurs / EDF | > +---------------------------------------------------------------+ > > [[alternative HTML version deleted]]
______________________________________________ R-help@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