[R] Histogram of multiple series on one histogram

Romain Francois francoisromain at free.fr
Fri Jun 3 20:37:51 CEST 2005


Hello alexandre,

what you are trying to do is *not* an histogram (as a density 
estimator), if you divide each bar in 3, the surfaces of a won't sum to 1.
However a barplot or a barplot2 (in package gplots, bundle gregmisc) 
would do the trick.
See graph 54 on the graph gallery :
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=54

BTW, don't call your vector 'c' unless you want funny things to happen

Romain


Le 03.06.2005 18:14, Depire Alexandre a écrit :

>Hello,
>I have three sample, for example
>	a<-c(10,20,10,20,30)
>	b<-c(10,20,20,30,30)
>	c<-c(20,20,10)
>
>I would like to have only one histogram with these series,
>I try the following code:
>	hist(a)
>	hist(b,add=TRUE,col="red")
>	hist(c,add=TRUE,col="green")
>but it's not that I want 
>
>I would like an histogram with, from left to right, count of "10" for "a", 
>count of "10" for "b", count of "10" for "c", count of "20" for "a", count of 
>"20" for "b", ... not overlapped
>
>Thanks
>
>
>  
>

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
~~~~~~      Romain FRANCOIS - http://addictedtor.free.fr         ~~~~~~
~~~~        Etudiant  ISUP - CS3 - Industrie et Services           ~~~~
~~                http://www.isup.cicrp.jussieu.fr/                  ~~
~~~~           Stagiaire INRIA Futurs - Equipe SELECT              ~~~~
~~~~~~   http://www.inria.fr/recherche/equipes/select.fr.html    ~~~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~




More information about the R-help mailing list