Skip to content

quilt.plot

2 messages · Dunja Drvar, Jim Lemon

#
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?
Thanks in advance,
        Dunja


Weather analysis and forecasting division
Meteorological and Hydrological Service
Gric 3, Zagreb HR-10000, Croatia
Tel: +385 1 4565 783
Fax: +385 1 4565 757
#
Dunja Drvar wrote:
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