Trying to use locator
in RStudio to get point or line coordinates, and nothing shows up until the locator
function is finished.
For example:
plot(1:10)
xy = locator(10, type="l")
then click in the plot. In a standard graphics device window (eg from windows()
or X11()
(or quartz()
? idk) you see the line drawn on each click. But the embedded RStudio graphics window shows nothing until the locator
function is finished.
There's a previous Q about this where someone has built a function that loops over locator(1)
to get one point, and then you can use lines
in the loop to draw between points and these do show up in the graphics window, but that's hard work for something that should work in the graphics window with locator(10, type="l")
.
I'm using RStudio 2022.02.3 Build 492 on Linux but have heard this is a common problem on other platforms too.