Hello,
I have the following problem: I need to crossplot two vectors (x and y) and am using scatter for it. Then I need to be able to identify the index of the point on which the user clicked. So, in short the code looks like this:
—————————
h=scatter(x,y,S,C); points=get(h,'Children');for i=1:numel(children)set(points(i),'HitTest','on','ButtonDownFcn',{'myFunction',i};end
—————————
I was hoping that the order of children is the same as order of elements in x and y. Looks like it is actually reversed. I could live with this, provided that Matlab guarantees that it will be always this way, i.e. that the relationship between the order of children and the order of x,y elements is fixed now and forever. x and y are not odrered, and searching by their values, which can be obtained from the src argument of the callback, is not very palatable: the vectors may be pretty large.
I'd appreciate any ideas.
Thank you,
Naum Derzhi
Best Answer