... but the best option is not to do this kind of technicolor extravaganza at all!
See ?dotplot (in lattice) and ?dotchart for better alternatives. Bert Gunter Genentech Nonclinical Statistics -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of hadley wickham Sent: Monday, December 03, 2007 8:30 AM To: Jim Lemon Cc: R-help@r-project.org; [EMAIL PROTECTED] Subject: Re: [R] using color coded colorbars for bar plots On 12/2/07, Jim Lemon <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hi Jim, > > Thanks for getting back to me so quickly. > > > > I did look at color.legend, but that seems to plot colored blocks for > > the observations (in this case the mean) and not for the color.scale > > (which represents variance in this case). Unless there is a > > functionality that I haven't discovered yet. If you have created a > > similar plot and would be happy to share some code I'd be very > > apprecitive. > > > Part of the problem is that you seem to have two names for the same > variable in your code (Standard.Deviance and Standard.Deviation - unless > that was a typo). Notice how I calculate the colors twice, the second > time with a simple integer sequence to get the right number of evenly > spaced colors. In your example, you calculated the colors for > RankVar$Standard.Deviance again, but you don't need all those colors for > the legend, and they're in the wrong order anyway. What is generally > wanted for a color legend is the minimum and maximum values on the ends > and a few linear interpolations in the middle. > > barplot(RankVar$MeanDecreaseAccuracy, > col=color.scale(RankVar$Standard.Deviance, > c(0,1,1),c(1,1,0),0), > ylab = "Variable Importance", > names.arg = rownames(RankVar), > cex.names = .7, > main = "Variables from RandomFishForest", > sub= "Mean Decrease in Accuracy") > col.labels<- c("Low","Mid","High") > color.legend(6,13,11,14,col.labels, > rect.col=color.scale(1:5,c(0,1,1),c(1,1,0),0)) Another option would be to use ggplot2: install.packages("ggplot2") library(ggplot2) qplot(rownames(RankVar), MeanDecreaseAccuracy, data = RankVar, colour = Standard.Deviance) and then use http://had.co.nz/ggplot2/scale_colour_gradient.html to control the choice of colours for the mapping. Regards, Hadley -- http://had.co.nz/ ______________________________________________ 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. ______________________________________________ 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.