Skip to content
Prev 255560 / 398506 Next

filled contour plot with contour lines

Steve,

I was just about to send off another suggestion which
began with ...

   Try the following or wait for David W. to chime in.

But I see that he's already done that. Anyway, in case
it's still of some use:

First I would check that you don't have a variable 'T' in
your workspace. (Never use T in place of TRUE.)

Then I would check that x and y are as they should be.

Then I would make sure that temp is of the correct type
(a matrix) by letting j take a few values (1,2,varsize[4]-1),
generating temp, and running str(temp). I assume that
varsize[4] is >= 2.

Then I would run the following stripped-down version of
your loop (note that I modified your contour() call):

  for(j in 1:2) {
       temp <- get.var.ncdf(nc=input,
                 varid="p_foraging",c(1,1,j),c(varsize[1],varsize[2],1)
               )
       filled.contour(x,
                      y,
                      temp,
                      plot.axes = { contour(x, y, temp, add = TRUE)
                            axis(1, seq(450000 , 580000, by = 10000))
                            axis(2, seq(2800000,4000000, by = 10000))
                      }
  }

If that gives reasonable results, you can add the prettyfying
statements back in. If you still get errors, then either I'm
out-to-lunch (quite possible!) or you need to use debug() to
figure out what's going on.

Peter Ehlers
On 2011-04-01 14:59, David Winsemius wrote: