[Rd] new function: showcolors {base}
Martin Maechler
Martin Maechler <maechler@stat.math.ethz.ch>
Fri Jan 24 16:50:04 2003
>>>>> "Wolfram" == Wolfram Fischer <- Z/I/M <wolfram@fischer-zim.ch>>
>>>>> on Fri, 24 Jan 2003 10:22:09 +0100 writes:
Wolfram> I propose to add a function that allows
Wolfram> to display colors selected by a text pattern
Wolfram> or by color vectors in a plot.
Wolfram> Wolfram Fischer
Wolfram> #--- showcolors.R
I had a much simpler idea
added to example(palettes) for R-devel (aka "pre-1.7.0") about
2 weeks ago:
Maybe one could combine some of the underlying ideas...
---
Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
##------ Some palettes ------------
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])
}
}
n <- if(.Device == "postscript") 64 else 16
# Since for screen, larger n may give color allocation problem
demo.pal(n)
Wolfram> showcolors <- function(
......