[R] contour( ..., method='edge') incompatible with xlim & ylim

david.schruth dschruth at gmail.com
Wed Feb 11 21:14:37 CET 2009


Hello,

A colleague of mine in our oceanography lab has pointed out a slightly
annoying imperfection with the contour plotting function.   It appears
that the 'edge' option for the 'method' parameter doesn't work very
well (or at all?) when xlim and ylim are also set.

The following code should recreate and demonstrate the problem:
---------------------------------------------------------------------------------------
library(marelac)
data(Bathyometry)

B <- Bathymetry

xrange <- c(-150, -120)
yrange <- c(40,60)

par(mfrow=c(1,2))

### using xlim and ylim ####
contour(B, xlim=xrange, ylim=yrange, method='edge', main='x/y
limited')

#### using subsetting ####
x <- !is.na(cut(B$x,breaks=xrange))
y <- !is.na(cut(B$y,breaks=yrange))
contour(B$x[x],B$y[y],B$z[x,y], method='edge', main="x/y subset")
----------------------------------------------------------------------------------------
Am I missing something or is this really a bug?  If so, I'd imagine
it's a relatively easy one to fix.

Thanks,

David Schruth
dschruth at u.washington.edu
Bioinformatics Research Consultant
The Center for Environmental Genomics
Department of Oceanography
University of Washington




More information about the R-help mailing list