I wrote a small MATLAB program with a gui. Inside the gui I have, among other things, a plot in which the user should be able to select two points. For this I use the function ginput, which creates a crosshair for selection. Unfortunatley the crosshair extends the whole window and is not restricted to the plot, which doesn’t look nice and is confusing for the user. How can the crosshair be restricted only to the area of the plot?
Share
Try using getpts, which doesn’t create the crosshair; with getpts, you can also specify the axes you want the user to select from, as in
The only trouble with getpts is there’s no way to limit it to exactly two points. But it does have the nice feature that the user can undo point selection by hitting DELETE, and confirm points by hitting ENTER.
looking closely at the ginput documentation, the behavior you describe is intended, and apparently unavoidable
from