Hi, I am using this loop par(mfrow=c(3,3)) annos<-c(2001:2007,2009) for (i in annos) { t<-subset(masia,YEAR==i) t$FAMILIA<-drop.levels(t$FAMILIA) pie(table(t$FAMILIA),main=i) }
To make piecharts of species composition among years (my data frame is called "masia"). So I get 1 piechart of the families that we have found in our survey each year. We don't have always the same families every year so I added t$FAMILIA<-drop.levels(t$FAMILIA) to the loop to avoid having those family levels that aren't there in some specific years in the pie The problem is that the color code changes and I get for example different colors for the same families in different years. If I group those families that I have less individuals together in a category called "others" and I make a new column called "familia2" with fewer levels so that every year I have all levels of familia2 in my species composition I don't get the problem and all families have the same color among years. Does anybody know how to avoid the color code change for the families in the loop. I know I can do it manually and give each family a color but I have quite a lot of families so I'm wondering if there's any way to fix that some other way. I don't know if I made myself clear... Thanks! Lucia -- View this message in context: http://r.789695.n4.nabble.com/color-code-in-loop-for-piecharts-plotting-tp3324196p3324196.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.