2

ロケーターを使用して挿入された最後のアイテム (テキスト ボックスなど) を削除するにはどうすればよいですか? すなわち

plot(1:3)
text(locator(1),labels="oops wrong spot...remove me",cex=1,font=1)
4

1 に答える 1

8

これを可能にするものを非常に簡単に実装できます。

locator <- function(...) {
    assign('.last.plot', recordPlot(), envir=.GlobalEnv)
    graphics::locator(...)
}

undo <- function()
   if (exists('.last.plot')) replayPlot(.last.plot)

plot(1:3)
text(locator(1),labels="oops wrong spot...remove me",cex=1,font=1)
undo()
于 2012-09-20T15:34:18.067 に答える