Hi I'm using polygon to delimit an area on a plot. However my intention is to "superpose" the outside area of the polygon (I want to cover an extrapolation of contour(interp(...)). Is there an easy way of doing it ? Thanks EJ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Hi > > I'm using polygon to delimit an area on a plot. However my > intention is to "superpose" the outside area of the polygon > (I want to cover an extrapolation of contour(interp(...)). > > Is there an easy way of doing it ? > > Thanks > > EJBelow is one way that may work. The last call to lines is (a kludge) to cover up the "retraced line" from the outer part of the polygon defined by the range of the plot data to the inner part of the polygon defined by your polygon of interest. n <- 50 * 3 x <- runif (n) y <- runif (n) x[(seq(n) %% 3) == 0] <- NA y[(seq(n) %% 3) == 0] <- NA plot.new () range.x <- range (x, na.rm=TRUE) range.y <- range (y, na.rm=TRUE) plot.window (range.x, range.y, asp=1) lines (x, y) wind.x <- c(range.x, rev (range.x), range.x[1]) wind.y <- c(range.y[1], range.y, rev (range.y)) polygon (wind.x, wind.y) poly.x <- wind.x / 2 + 0.25 poly.y <- wind.y / 2 + 0.25 polygon (poly.x, poly.y) mask.x <- c(wind.x, poly.x) mask.y <- c(wind.y, poly.y) polygon (mask.x, mask.y, col="white") lines (c(wind.x[1], poly.x[1]), c(wind.y[1], poly.y[1]), col="white") -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
An even better solution, obviating the extra call to lines is: n <- 50 * 3 x <- runif (n) y <- runif (n) x[(seq(n) %% 3) == 0] <- NA y[(seq(n) %% 3) == 0] <- NA plot.new () range.x <- range (x, na.rm=TRUE) range.y <- range (y, na.rm=TRUE) plot.window (range.x, range.y, asp=1) lines (x, y) wind.x <- c(range.x, rev (range.x), range.x[1]) wind.y <- c(range.y[1], range.y, rev (range.y)) # example polygon poly.x <- wind.x / 2 + 0.25 poly.y <- wind.y / 2 + 0.25 mask.x <- c(wind.x, poly.x) mask.y <- c(wind.y, poly.y) polygon (mask.x, mask.y, col="white", border="white") -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi Thanks for your help. EJ On Mon, 2002-09-30 at 16:28, white.denis at epamail.epa.gov wrote:> An even better solution, obviating the extra call to lines is: > > n <- 50 * 3 > x <- runif (n) > y <- runif (n) > x[(seq(n) %% 3) == 0] <- NA > y[(seq(n) %% 3) == 0] <- NA > > plot.new () > range.x <- range (x, na.rm=TRUE) > range.y <- range (y, na.rm=TRUE) > plot.window (range.x, range.y, asp=1) > lines (x, y) > > wind.x <- c(range.x, rev (range.x), range.x[1]) > wind.y <- c(range.y[1], range.y, rev (range.y)) > > # example polygon > poly.x <- wind.x / 2 + 0.25 > poly.y <- wind.y / 2 + 0.25 > > mask.x <- c(wind.x, poly.x) > mask.y <- c(wind.y, poly.y) > polygon (mask.x, mask.y, col="white", border="white")-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._