Jim, Thanks for such a quick response. It works well. Is it possible to fill the bars with patterns and colours? Regards, Deb
Jim Lemon <[EMAIL PROTECTED]> wrote: Deb Midya wrote: > Hi R Users! > > Thanks in advance. > > I am using R-2.5.1 on Windows XP. > > I am trying to do a stacked bar plot, but could not get through the following > problem. The code is given below. > > 1. How can I provide 15 different colors for each method with 15 Rows? > > 2. How can I put the legend in a particular position (eg., in the top or > bottom or right or left)? How can I put legend using a number of rows (eg., > using two or three rows)? > Hi Deb, As you have probably noticed, the integer coded colors repeat too quickly for the number of colors you want. You can use the rainbow() function to generate colors like this: barplot(x,beside=FALSE,col=rainbow(nrow(x))) or there are lots of other color generating functions in the grDevices or plotrix packages. Here's how to get your legend in an empty space for your plot. There is also an emptyspace() function in the plotrix package that tries to find the biggest empty space in a plot, although it probably wouldn't work in this case. legend(0,1000,rownames(x),fill=rainbow(nrow(x))) Jim --------------------------------- [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.