[R] quilt.plot
Jim Lemon
jim at bitwrit.com.au
Sat Jan 13 04:21:59 CET 2007
Dunja Drvar wrote:
> Dear all,
> I have a problem with plotting.
> I have an irregular set of data, where latitude is listed from bigger to
> smaller values. So, I cannot plot with image.plot.
> On the other hand, quilt.plot solves the problem, but it can't take the
> definition of color. It gives the feedback:
>
> Error in image.plot(out.p, col = tim.colors(64), ...) :
> formal argument "col" matched by multiple actual arguments
>
> The question is: is there a way to define the color palette in quilt.plot?
Hi Dunja,
I think the problem is due to the position of the ... argument. In
image.plot it is first, meaning that all other arguments have to be
named. Thus when you pass col= as part of ... in quilt.plot, it is
placed in the initial ... in the call to image.plot, generating two col=
arguments. I think the quickest hack is to insert an explicit col=
argument into the code for quilt.plot and add it into the call to
image.plot within the function as below.
function (x, y, z, nrow = 64, ncol = 64, grid = NULL, add.legend = TRUE,
col=tim.colors(64), ...)
{
x <- as.matrix(x)
if (ncol(x) == 2) {
z <- y
}
if (ncol(x) == 1) {
x <- cbind(x, y)
}
if (ncol(x) == 3) {
z <- x[, 3]
x <- x[, 1:2]
}
out.p <-
as.image(z, x = x, nrow = nrow, ncol = ncol, na.rm = TRUE)
if (add.legend) {
image.plot(out.p, col = col, ...)
}
else {
image(out.p, col = col, ...)
}
}
The modified example:
quilt.plot(ozone2$lon.lat, ozone2$y[16, ],
add.legend = FALSE,col=rainbow(64))
works for me.
Jim
More information about the R-help
mailing list