Re: [R] quilt.plot

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Sat 13 Jan 2007 - 03:21:59 GMT

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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Jan 13 14:29:44 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 13 Jan 2007 - 06:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.