Description Usage Arguments Details Value Author(s) References See Also Examples
Functions to generate a selection of color vectors for spectrograms based on existing color vectors for images in grDevices. Vectors are reversed relative to their parent (i.e. numerical sequences progress from 1 to 0 rather than 0 to 1).
1 2 3 4 5 |
n |
A vector of desired color levels between 1 and 0; one indicates high amplitude ("black", "red", or "blue") and zero indicates low amplitude ("white", "purple", or "tan"). |
The n
argument will divide the vector into n
color levels.
A vector of colors.
Jon Katz, Sasha D. Hafner
Based on the color palettes from grDevices, and loosely on those used in seewave
gray
, rainbow
, topo.colors
, terrain.colors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | spec.test <- function(mat, spec.col) image(z = t(mat), col = spec.col)
mat <- matrix(1:30, ncol = 6, byrow = TRUE)
spec.test(mat = mat, spec.col = gray.1())
spec.test(mat = mat, spec.col = gray.2())
spec.test(mat = mat, spec.col = gray.3())
spec.test(mat = mat, spec.col = rainbow.1())
spec.test(mat = mat, spec.col = topo.1())
## Not run:
# Colors are defined as:
gray.1 <- function(n = 30) gray(seq(1, 0, length.out = n))
gray.2 <- function(n = 30) gray(1-seq(0, 1, length.out = n)^2)
gray.3 <- function(n = 30) gray(1-seq(0, 1, length.out = n)^3)
rainbow.1 <- function(n = 15) rev(rainbow(n))
topo.1 <- function(n = 12) rev(topo.colors(n))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.