[R] Multiple stacked barplots on the same graph?

John Kane jrkrideau at yahoo.ca
Tue Dec 4 18:19:42 CET 2007


--- Domenico Vistocco <vistocco at unicas.it> wrote:

> 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

Very nice but bit garish. :)

What about a dotchart instead?

 dotchart(x, labels=rownames(x),col=c(1:4), pch=16)



> 
> 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.
> >
> >
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



More information about the R-help mailing list