Question

Using ginput (or ginputax) I ask my user to click on an axes 10 times (for spectrum baseline correction).

My axes is based on a GUIDE GUI.

Essentially this begins like this

plot(handles.axes_preview, ppm, xf_base, 'w-', 'LineWidth', 2);

spline_ppm = ginputax(handles.axes_preview, 10);

I'd like to plot each click (as ro) as they're being input, so the user has some feedback of where they clicked.

Any ideas how to code this?

Was it helpful?

Solution

How about a simple loop?

axis(handles.axes_preview); %// make handles.axes_preview the current axis
hold on
for ii = 1:10
    coords(ii,:) = ginput(1);
    plot(coords(ii,1),coords(ii,2),'ro')
end

Also, you may want to add

set(handles.axes_preview),'XLimMode','manual');
set(handles.axes_preview),'YLimMode','manual');

at the beginning to prevent the axis scale from automatically changing as points are input by the user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top