Has anyone yet tried incorporating rasterImage into the base image()
function? It seems to make a *huge* difference, with
a very small number of added/changed lines of code. (Of course I have
barely tested it at all.)
Is there any reason this *shouldn't* go into the next release?
> source("image.R")
> z <- matrix(runif(1e6),nrow=1000)
> image(z)
> image(z,useRaster=TRUE)
(Patch against SVN 54284 attached; people can contact me if it doesn't
go through and they want it.)
Ben Bolker
Index: image.R
===================================================================
--- image.R (revision 53953)
+++ image.R (working copy)
@@ -24,7 +24,8 @@
ylim = range(y),
col = heat.colors(12), add = FALSE,
xaxs = "i", yaxs = "i", xlab, ylab,
- breaks, oldstyle=FALSE, ...)
+ breaks, oldstyle=FALSE,
+ useRaster=FALSE, ...)
{
if (missing(z)) {
if (!missing(x)) {
@@ -97,5 +98,12 @@
if (length(y) <= 1) y <- par("usr")[3:4]
if (length(x) != nrow(z)+1 || length(y) != ncol(z)+1)
stop("dimensions of z are not length(x)(-1) times length(y)(-1)")
- .Internal(image(as.double(x), as.double(y), as.integer(zi), col))
+ if (useRaster) {
+ zc <- col[zi+1]
+ dim(zc) <- dim(z)
+ rasterImage(as.raster(zc),
+ xlim[1],ylim[1],xlim[2],ylim[2],interpolate=FALSE)
+ } else {
+ .Internal(image(as.double(x), as.double(y), as.integer(zi), col))
+ }
}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel