R plot cancel line?

Is there a quick and easy function to undo a segment or remove it from your plot?

    p1 <- locator(1)
    p2 <- locator(1)
    segments(p1$x, p1$y, p2$x, p2$y, col = 'pink')
    //Undo segments

I want to say whether it is possible to save the line segment (color / intensity of each pixel) that you are going to erase, and then add this line segment in which the pink segment was actually canceled. How to do it?

+2
source share
2 answers

You can do it with Grid Graphics,

library(grid)
ll = replicate(2, grid.locator())
g = grid.segments(ll[,1]$x, ll[,1]$y, ll[,2]$x, ll[,2]$y, 
      name="mysegment", gp=gpar(col="pink", lwd=5))
grid.remove("mysegment")
+6
source

No. The best thing you can do if you’re not using gridit is to write the graphic above the offensive color segment in the background color (i.e. segments(p1$x, p1$y, p2$x, p2$y, col = 'white'), if the background is white, it’s a hack that sometimes fails).

, ; R ( Paul Murrell grid, @baptiste, rgl 3D-), , . R "", ; .

+3

All Articles