Am 28.07.2011 03:25, schrieb Fernando Andreacci:
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?
Thanks
Hey,
this good?
hex <- function(dec){
stopifnot(round(dec)==dec && dec >= 0 && dec <= 100) # error checking
line
dec <- round(dec * 2.55) # scale 0-100 to 0-255
class(dec) <- "hexmode" # transform to hex
dec <- format(dec, width=2) # convert e.g. "3" to "03"
paste("#", dec, dec, dec, sep="") # generate a #RRGGBB code, e.g. #030303
}
plot(1:11, col=hex(seq(0,100,by=10)))
Have fun,
Alex
______________________________________________
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.