Dear all, I want to draw a barplot with the following data: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [1,] 110.0675 118.4167 117.16 109.735416 101.6312 104.0312 101.8263 99.38541670 114.2613 [2,] 0.0000 0.0000 0.00 1.658333 0.0000 0.6250 0.0000 0.05208333 0.0000 [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [1,] 46.597917 108.5312 99.85833 104.3137 99.07917 95.5975 92.07292 108.6338 104.82917 [2,] 2.458333 0.0000 2.62500 0.0000 0.18750 0.0000 0.00000 0.0000 0.40625 [,19] [,20] [1,] 48.90625 47.5 [2,] 0.00000 0.0 The problem is: I want to group the data. I want to have ten groups. The first two bars should be [1,1] and [2,1] together in one bar and in the second bar of the first obervation should be [1,2] and [2,2] (stacked with beside =TRUE). Therefore the first observation is [1,1],[1,2],[2,1] and [2,2]. For a better understanding: I want to split the darkblue bar into a green and a blue bar (please see picture) per observation. Has anyone a suggestion how I can do this? Thank you very much in advane. http://n4.nabble.com/file/n1679227/Pic.jpg -- View this message in context: http://n4.nabble.com/barplot-stacked-tp1679227p1679227.html Sent from the R help mailing list archive at Nabble.com.
Hi Jens! 23.03.2010 17:18, koj wrote:> The problem is: I want to group the data. I want to have ten groups. The > first two bars should be [1,1] and [2,1] together in one bar and in the > second bar of the first obervation should be [1,2] and [2,2] (stacked with > beside =TRUE). Therefore the first observation is [1,1],[1,2],[2,1] and > [2,2].I am not sure that I wholly understood what You want :) But why not use lattice 'barchart' instead: Let's suppose 'dm' is your data matrix. Please try the following command and let us know, if the output is what you are looking for: barchart(~dm[,1]+dm[,2], stacked=T) HTH, Kimmo
Hi Kimmo, thank you for your answer, but this is not the thing I am searching for. Unfortunately, I have not described the problem very good. But just in this moment I have a good idea: I use add=TRUE and paint two plots. And so I am sure that I can solve the problem. -- View this message in context: http://n4.nabble.com/barplot-stacked-tp1679227p1680485.html Sent from the R help mailing list archive at Nabble.com.
Hi Jens! 24.03.2010 14:48, koj wrote> > Hi Kimmo, thank you for your answer, but this is not the thing I am searching > for. Unfortunately, I have not described the problem very good. But just in > this moment I have a good idea: I use add=TRUE and paint two plots. And so I > am sure that I can solve the problem.Just to satisfy my curiosity: does the following code solve Your problem (once again, dm refers to your data matrix): --- cut here --- barplot(dm[,seq(1,20,2)], col="grey", space=2) barplot(dm[,seq(2,20,2)], add=T, col=c("blue","green"), space=c(3,rep(2,9))) --- cut here --- Regards, Kimmo