Reading mouse input
Below is a list of sample approaches to first the problem, from the most complex to simplest (IMHO).
- I would recommend that you have a look at the
qtpaint
package.
- Less laborious solution may involve looking at the way interactive
plots in Shiny are handled. Using the
click
option would
enable you to get the mouse cursor position. Together with the Shiny
framework this would provide a convenient wrapper to get mouse input
from a user.
- Finally, third approach could rely on making use of the
locator
function available in the graphics
package. Depending on what you intend to do, this may be the simplest solution as you could then use read values to inform generation of your graphic.
Generating graphics
Assuming that you got your values via the locator
functionality you could attempt to draw your line using segments
. It would be a little fiddly as you would have to translate your coordinates to some placement of the dot in your desired chart but this wouldn't computationally too taxing, just a matter of bring mouse pointer values to some x/y
values on the chart.
If you care to update your post with a sample code and reproducible attempts of your previous work, I bet the question will receive more replies. You may find this discussion on making a reproducible example in R helpful.