[R] colored rasterImage()

Ben Tupper
Fri, 01 Oct 2010 02:50:01 -0000

Hello,

I have been exploring the possibility to transition some code that
currently uses image() to use the new rasterImage().  To date, I
haven't been able to specify a color look-up strategy that works.  For
example...

nx <- 100
ny <- 100
m <- matrix(data = rep(seq(0,1, length = nx), ny), ncol = nx, nrow =
ny, byrow = TRUE)
plot(1:nx, 1:ny, type = "n")
my.color <- matrix(data = (rainbow(100))[m*100], ncol = nx, nrow = ny,
byrow = TRUE)
rasterImage(m, 1, 1, nx, ny, col = my.color)

This yields a greyscale image. Is it possible to create colored images
using rasterImage, and, if so, what is the correct way to generate a
colored image using rasterImage?

Also, is there a vignette or tutorial on using the new rasterImage()
and related functions?

Thanks!
Ben Tupper
Bigelow Laboratory for Ocean Science
www.bigelow.org

 > R.Version()
$platform
[1] "i386-apple-darwin9.8.0"

$arch
[1] "i386"

$os
[1] "darwin9.8.0"

$system
[1] "i386, darwin9.8.0"

$status
[1] ""

$major
[1] "2"

$minor
[1] "11.1"

$year
[1] "2010"

$month
[1] "05"

$day
[1] "31"

$`svn rev`
[1] "52157"

$language
[1] "R"

$version.string
[1] "R version 2.11.1 (2010-05-31)"