Sergey Goriatchev wrote: > Hello, > > Let me describe what I have and what I want to do: > > I have two (7x6) matrices (call them A and B) that have same row and > column names (rows=species, columns=variables) but contain numerical > values that differ (same experiment done twice and values calculated > and put in different matrices). > ... > But this is not very effective. What I want to do is to combine the > two similar barplots for each experiment into one. So, for each > species I create just one barplot where I plot 6 clusters each > consisting of 2 bars, one bar for same varibale but different > experiment. I want to put the values as text at the top of each bar > and below each cluster I want to put the name of the variable (they > are the same for each experiment, remember). > Hi Sergey, See if this does what you want:
library(plotrix) mat1<-matrix(rnorm(42,3),nrow=7) mat2<-matrix(rnorm(42,3),nrow=7) colnames(mat1)<-colnames(mat2)<- c("First","Second","Third","Fourth","Fifth","Sixth") rownames(mat1)<-rownames(mat2)<- c("Fextus decrepitans","Gryphon laxus", "Domus flaccidus","Cogitans prostrata","Osmia putrescens", "Aria excruciata","Pestis ubiquitus") maintitle<-paste("Plot of",rownames(mat1)[1]) barp(rbind(mat1[1,],mat2[1,]),names.arg=colnames(mat1), col=c(2,3),main=maintitle,ylim=c(0,6)) text(1:6-0.2,mat1[1,]+0.3,round(mat1[1,],2),srt=90) text(1:6+0.2,mat2[1,]+0.3,round(mat2[1,],2),srt=90) ... Jim ______________________________________________ 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.