From: jia ding <dingjia_at_gmail.com>

Date: Fri 24 Feb 2006 - 21:58:58 EST

box()

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 Received on Fri Feb 24 23:17:43 2006

Date: Fri 24 Feb 2006 - 21:58:58 EST

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 <francoisromain@free.fr> 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 Received on Fri Feb 24 23:17:43 2006

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:42:45 EST
*