Locator function getting stuck

locator() is part of the graphics package (it's not specific to Fragman), and depends to some extent on non-R system components. Can you provide some more system information? For example:

  • OS Version:
  • R Version:
  • Are you running R via RStudio? If so...
    • RStudio Edition: (Desktop or Server)
    • RStudio Version:
  • The output of running dev.capabilities() (to check whether your R thinks the default device can support locator())

Finally, can you use locator() on a basic plot, such as this?

plot(mtcars$cyl, mtcars$disp)
my.panel <- locator(type='p', pch=20, col='red')$x

Expected behavior:

  • The plot should appear in a plot window (in RStudio, this will be in the Plots pane).
  • When you run the locator() line, the console will be busy (no prompt) and you will be able to click on the plot (the mouse cursor will turn into a crosshair when you hover over the plot).
  • After clicking several times, exit locator() (usually Esc, but the way to exit can be system-specific — see the documentation linked above).
  • Red dots will show up on the plot in the places you clicked.
  • The console should be available again and you can inspect the values that were saved in my.panel.

Does all of that work as expected on the mtcars plot?

1 Like