Thank you very much, Deepayan. There is just one more feature I'd
like to get, the ability to add the contour lines. My revision to
your code below prints too many lines. What needs to be changed?
You need to name arguments here. as.double(at) is being
matched to 'nlevels', but you want 'levels'.
Another option is to use panel.levelplot() for the contours.
E.g., (also with more accurate 'x' and 'y'):
panel.filledcontour <-
function(x, y, z, subscripts,
at,
col.regions = cm.colors,
col = col.regions(length(at) - 1),
...)
{
stopifnot(require("gridBase"))
z <- matrix(z[subscripts],
nrow = length(unique(x[subscripts])),
ncol = length(unique(y[subscripts])))
if (!is.double(z)) storage.mode(z) <- "double"
opar <- par(no.readonly = TRUE)
on.exit(par(opar))
if (panel.number() > 1)
par(new = TRUE)
par(fig = gridFIG(), omi = c(0, 0, 0, 0), mai = c(0, 0, 0, 0))
cpl <- current.panel.limits()
plot.window(xlim = cpl$xlim, ylim = cpl$ylim,
log = "", xaxs = "i", yaxs = "i")
.Internal(filledcontour(as.double(sort(unique(x[subscripts]))),
as.double(sort(unique(y[subscripts]))),
z, as.double(at), col = col))
panel.contourplot(x, y, z, subscripts = subscripts, at = at,
region = FALSE, contour = TRUE, labels = FALSE) }