I'm updating some (very) old code, and one particular option of its plot method depends on
a once-was-true trick
polygon(x, y, border=TRUE, col=0)
polygon(x, y, border=TRUE, density=0)
would draw the polygon AND erase whatever was underneath it back to background color.
Is there a reliable way to do this with the current R (standard graphics)?
Terry Therneau
PS For the inquiring, the routine is text.rpart with the fancy=T option, and the original
target was the postscript driver on Splus 3.4. (I said it was old.) The plot.rpart
routine draws the branches, and text.rpart then wants to lay down some ellipses, erasing
what is underneath them.
erasing a polygon
3 messages · Terry Therneau, PIKAL Petr
Hi It seems that it still works. x<-c(3,7,7,3) y<-c(4,4,6,6) par(bg="pink") plot(1:10,1:10) polygon(x, y, border=TRUE, col=0)
version
_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Under development (unstable) major 2 minor 16.0 year 2012 month 03 day 03 svn rev 58569 language R version.string R Under development (unstable) (2012-03-03 r58569)
Regards Petr
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Terry Therneau
Sent: Thursday, September 27, 2012 2:37 PM
To: r-help at r-project.org
Subject: [R] erasing a polygon
I'm updating some (very) old code, and one particular option of its
plot method depends on a once-was-true trick
polygon(x, y, border=TRUE, col=0)
polygon(x, y, border=TRUE, density=0)
would draw the polygon AND erase whatever was underneath it back to
background color.
Is there a reliable way to do this with the current R (standard
graphics)?
Terry Therneau
PS For the inquiring, the routine is text.rpart with the fancy=T
option, and the original target was the postscript driver on Splus 3.4.
(I said it was old.) The plot.rpart routine draws the branches, and
text.rpart then wants to lay down some ellipses, erasing what is
underneath them.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.
I was able to puzzle it out with the help of the book "R Graphics" (Murrell).
When par("bg") = "transparenent" one needs to use col="white", otherwise the
old code col=0 works correctly.
The default for pdf and x11, the two I use, is transparent.
Terry Therneau
On 09/27/2012 08:48 AM, PIKAL Petr wrote:
Hi It seems that it still works. x<-c(3,7,7,3) y<-c(4,4,6,6) par(bg="pink") plot(1:10,1:10) polygon(x, y, border=TRUE, col=0)
Sent: Thursday, September 27, 2012 2:37 PM
To: r-help at r-project.org
Subject: [R] erasing a polygon
I'm updating some (very) old code, and one particular option of its
plot method depends on a once-was-true trick
polygon(x, y, border=TRUE, col=0)
polygon(x, y, border=TRUE, density=0)
would draw the polygon AND erase whatever was underneath it back to
background color.
Is there a reliable way to do this with the current R (standard
graphics)?
Terry Therneau
PS For the inquiring, the routine is text.rpart with the fancy=T
option, and the original target was the postscript driver on Splus 3.4.
(I said it was old.) The plot.rpart routine draws the branches, and
text.rpart then wants to lay down some ellipses, erasing what is
underneath them.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code.