Re: [R] 2 barplots in the same graph

From: Romain Francois <francoisromain_at_free.fr>
Date: Fri 24 Feb 2006 - 21:31:26 EST

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                                  |
+---------------------------------------------------------------+

______________________________________________
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 21:49:08 2006

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