I’m visualising some data using filled.contour() with the following code:
filled.contour(x, y, z, col = rainbow(256),nlevels=(256),
plot.title = title(main = "z",
xlab = "x", ylab = "y"),
key.title = title(main="T"),
)
which generates the following plot:
However, when I try and log the data, the colour palette is recycled, which makes the point of this kind of image a bit pointless…:
filled.contour(x, y, log(z), col = rainbow(256),nlevels=(256),
plot.title = title(main = "z",
xlab = "x", ylab = "y"),
key.title = title(main="T"),
)

I have also tried z <- log(z) and then calling filled.contour(x,y,z,...) but this produces the same result. I have tried changing the values passed to col=rainbow() and nlevels() but this also doesn’t make any difference.
I can reproduce a similarly weird plot if I have negative values in my matrix (and hence NA/NaN values in my log(z) matrix):
I used
pmaxto fix things up, your solution may depend on your problem.I’m not sure that’s your problem, but since you haven’t given us a reproducible example …
I have to say that I haven’t really found the root of the problem — the simple example below gives reasonable answers even with
Infvalues — but I don’t have time to dig further right now.