Re: [R] Ploting graphics using X tints from a color

From: Ben Bolker <bolker_at_ufl.edu>
Date: Wed 14 Dec 2005 - 08:14:31 EST

Sérgio Nunes <snunes <at> gmail.com> writes:

>
> Hi,
>
> I'm trying to draw a 2D plot using multiple tints of red. The
> (simplified) setup is the following: || year | x | y ||
>
> My idea is that each year is plotted with a different tint of red.
> Older year (lightest) -> Later year (darkest).

 how about:

x = runif(300)
y = runif(300)
year = factor(rep(1:30,each=10))

nyear = length(levels(year))
grays = gray((nyear:0)/nyear)
reds = hsv(h=1,s=(0:nyear)/nyear,v=1)

plot(x,y,col=grays[as.numeric(year)],pch=16) plot(x,y,col=reds[as.numeric(year)],pch=16)

plot(x,y,bg=reds[as.numeric(year)],pch=21,fg=1) legend(0.8,1,levels(year),pch=21,pt.bg=reds,col=1,bg="white",ncol=2)



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 Received on Wed Dec 14 09:55:05 2005

This archive was generated by hypermail 2.1.8 : Wed 14 Dec 2005 - 14:38:24 EST