s-news
[Top] [All Lists]

[S] Summary on closed contour problem

To: s-news <s-news@wubios.wustl.edu>
Subject: [S] Summary on closed contour problem
From: Tim Smith <tsmith@whsun1.wh.whoi.edu>
Date: Wed, 28 Apr 1999 15:20:30 -0400
Reply-to: Tim.Smith@noaa.gov
Sender: owner-s-news@wubios.wustl.edu
I inquired recently about how to keep the contour lines returned by
contour(save=T) from being a collection of unconnected line segments. 
Bill Dunlap suggested putting up a fence around the data; it works well
on all of the problem data sets I had.

Bill provided example code, below; of course one needs to expand the x
and y vectors to match, but that's straightforward. 

Steve Smith also suggested polygon() and poly.area().  I am using
poly.area() on the output of contour, but couldn't see where polygon()
did more than draw polygons.  If it does it would be worth looking at
also.

Patrick Connolly noted a possibly related peculiar behavior of
contour(), part of which is having contours labeled multiple times. 
This is likely associated with my problem, and I would imagine would be
fixed by Bill's solution.

Bill's solution would seem useful to have as a well worked out option in
contour().


Bill wrote:
Have you tried forcing closed contours by surrounding your data
by a ring of very large (positive or negative) values?  E.g.,

        my.contour <- function(z, nlevels = 5,
                v = signif(pretty(z, nlevels), 3), ...) {
                z0 <- min(z, na.rm=T) - 10 * diff(range(z, na.rm=T)) -
100
                v <- v
                z <- rbind(z0, z, z0)
                z<- cbind(z0, z, z0)
                contour(z, nlevels=nlevels, v=v, ...)
        }


-- 
Tim D Smith
Northeast Fisheries Science Center
166 Water St
Woods Hole, Massachusetts 02543 USA

email:  Tim.Smith@noaa.gov
voice:  508-495-2251
fax:    508-495-2258
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>
  • [S] Summary on closed contour problem, Tim Smith <=