I have a plot figure and I want to retreive x and y cordinates when we select particular data point using mouse from plot figure.
Any ideas?
Another option is to use the button down function:
function mouseExample()
h = plot(rand(10,1), 'o-');
set(h, 'ButtonDownFcn',@buttonDownCallback)
function buttonDownCallback(o,e)
p = get(gca,'CurrentPoint');
p = p(1,1:2);
title( sprintf('(%g,%g)',p) )
end
end
Note this will not only work on "data-points", but rather on interpolated (x,y) positions of where you clicked on the lines. You could process the result by searching for the nearest actual point, and test if the click was within a reasonable radius to accept it.
Obviously it is a lot easier to just use the data cursor mode as other have noted...