On 07/28/2011 11:25 AM, Fernando Andreacci wrote:
I have a simple bar chart with annual precipitation (jan to dez).
I want to plot, above each bar (on a line), a square wich is color based on
a scale (0-100%). With 0 being white and 100 black, like a gradient. Is it
possible? How to?
Hi Fernando,
I think you want the grayscale to reflect the values of the percentages,
so here is one way to do it:
# make up some values for the bars
barvalues<-sample(0:9,10)
# make up some values for the percentages
pctvalues<-sample(0:100,10)
# draw a barplot
xpos<-barplot(barvalues,ylim=c(0,10))
# translate the percent values into grayscale
pctcolors<-color.scale(pctvalues)
rect(xpos-0.3,barvalues+0.5,xpos+0.3,barvalues+1,col=pctcolors)
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.