Multiple stacked barplots on the same graph?
On Dec 4, 2007 11:19 AM, John Kane <jrkrideau at yahoo.ca> wrote:
--- 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)
which would be (roughly equivalent to) qplot(X2, value, data=dfm, colour=X2, facets = . ~ X1) in ggplot. Hadley