# NOT RUN {
cubeHelix(21)
# }
# NOT RUN {
cols = cubeHelix(101)
plot.new()
plot.window(xlim=c(0,1), ylim=c(0,1))
axis(side=1)
for (i in 1:101) {
rect((i-1)/101,0,(i+0.1)/101,1, col=cols[i], lwd=0)
}
# }
# NOT RUN {
# }
# NOT RUN {
require(grDevices)
# comparison with other palettes
n = 101
cols = cubeHelix(n)
heat = heat.colors(n)
rain = rainbow(n)
terr = terrain.colors(n)
plot.new()
plot.window(xlim=c(-0.5,1), ylim=c(0,4))
axis(side=1, at=c(0,1))
axis(side=2, at=1:4-0.5, labels=1:4, pos=0)
for (i in 1:n) {
rect((i-1)/n,3,(i+0.1)/n,3.9, col=cols[i], lwd=0)
rect((i-1)/n,2,(i+0.1)/n,2.9, col=heat[i], lwd=0)
rect((i-1)/n,1,(i+0.1)/n,1.9, col=rain[i], lwd=0)
rect((i-1)/n,0,(i+0.1)/n,0.9, col=terr[i], lwd=0)
}
legend(-0.6,4,legend=c("4. cube helix", "3. heat", "2. rainbow", "1. terrain"), box.lwd=0)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab