A explicação do script a seguir está no artigo R na Prática – Parte 29.
#https://www.rdocumentation.org/packages/
#grDevices/versions/3.6.2/topics/Palettes
#setwd("C:\\geoStats\\figuras\\chap3")
#jpeg("Fig3_20.jpeg",width=5,height=5,
#units="in",res=300)
demo.pal <-
function(n, border = if (n < 32) "light gray" else NA,
main = paste("color palettes; n=", n),
ch.col=c("rainbow(n,start=.7,end=.1)",
"heat.colors(n)","terrain.colors(n)",
"topo.colors(n)","cm.colors(n)"))
{
nt <- length(ch.col)
i <- 1:n; j <- n / nt; d <- j/6; dy <- 2*d
plot(i, i+d, type = "n", yaxt = "n", ylab = "",
main = main)
for (k in 1:nt) {
rect(i-.5, (k-1)*j+ dy, i+.4, k*j,
col = eval(parse(text = ch.col[k])),
border = border)
text(2*j, k * j + dy/4, ch.col[k])
}
}
demo.pal(21)
#dev.off()