Hi Brindha Does this answer your question: http://onertipaday.blogspot.com/2007/05/make-many-barplot-into-one-plot.html ?
Cheers, Tal On Wed, Jul 29, 2009 at 8:48 PM, Brindha Selvaraj <brindharh...@gmail.com>wrote: > Hi, > > Many apologies for sending this twice. I accidentally hit the send button > before I finished writing my mail. I am new to R and I hope someone can > help me with my problem. I am trying to draw a side by side barplot. > > There is a main experiment and there are many sub experiments within the > main experiment. I would like to draw a bar plot showing the number and > type > of sub_experiments done for each main_exp. For instance if the Main_Exp is > 6, I would like to group the sub exp's for the main_exp and show that there > were two sub_exp's done an ELISA and a FCM and that the ELISA was done once > and the FCM was done twice. Similarly for Main_Exp 7 I would like to show > that for there were ELISA,FCM,qPCR,Telometry done and that they had a count > of 3,3,2,5 respectively. This is what my dataset looks like: > > Main_Exp_Name Sub_Exp_Name Sub_Exp_Count > 1 ELISA 2 > 6 ELISA 1 > 6 FCM 2 > 7 ELISA 3 > 7 FCM 3 > 7 Telometry 2 > 7 qPCR 5 > > The code that I have is > > table(comparisons_new) > barplot(as.matrix(comparisons_new$Sub_Exp_Count),xlab="Main_Exp_Name", > > ylab="Sub_Exp_Count",ylim=c(0,10),names.arg=(comparisons_new$Main_Exp_Name),beside=TRUE,legend=rownames(comparisons_new$Sub_Exp_Name),col=rainbow(5)) > > With this code, I am able to draw the barplot, but am having issues: > > I am not able to group them together. That is for each Main_Exp I am not > able to group the Sub_Exp's under it. It all shows up as one continuous > barplot without any spaces in between the Main_Exp's. > > Also, I would like to be able to use the same colour for a particular > sub_Exp_Name no matter in which ever Main_Exp it may show up. But, this is > not working for me. > > Please help, > > Brinda > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > -- ---------------------------------------------- My contact information: Tal Galili Phone number: 972-50-3373767 FaceBook: Tal Galili My Blogs: http://www.r-statistics.com/ http://www.talgalili.com http://www.biostatistics.co.il [[alternative HTML version deleted]] ______________________________________________ R-help@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.