Skip to content
Prev 82703 / 398506 Next

Ploting graphics using X tints from a color

SÃ©rgio Nunes <snunes <at> gmail.com> writes:
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)