[R] Multiple stacked barplots on the same graph?

Domenico Vistocco vistocco at unicas.it
Tue Dec 4 16:41:29 CET 2007


Perhaps this could be useful:
 > x=scan()
11.81 10.51  1.95  2.08  2.51  2.05  1.98  0.63  0.17  0.20
12.49 13.56 2.81  3.13  4.58  0.70  0.85  0.22  0.06  0.03

 > x=matrix(x,5,4,byrow=T)
 > rownames(x)=paste("comp",1:5,sep="")
 > colnames(x)=paste("c",1:4,sep="")

 > library(ggplot2)
 > dfm=melt(x)
 > qplot(as.factor(x=X1),y=value,geom="histogram",data=dfm,fill=X2)

domenico vistocco

Stéphane CRUVEILLER wrote:
> Dear R-Users,
>
> I would like to know whether it is possible to draw several
> stacked barplots (i.e. side by side on the same sheet)...
>
>
> my data look like :
>
>                             Cond1  Cond1' Cond2   Cond2'
> Compartment 1    11,81    2,05    12,49    0,70   
> Compartment 2     10,51    1,98    13,56    0,85
> Compartment 3     1,95    0,63    2,81    0,22  
> Compartment 4     2,08    0,17    3,13    0,06   
> Compartment 5     2,51    0,20    4,58    0,03
>
> ps: Cond1' values should be stacked on Cond1, Cond2' on Cond 2 and so 
> on... and series 1 and 2
> should be side by side for each compartement....
>
> Thanks for any help.
>
> Stéphane.
>
>



More information about the R-help mailing list