Can the ButtonDownFcn of a plot object identify which point has been clicked?
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
Is there a way that I can allow the callback to the clicking into a plot or scatter object to recognize which individual point has been clicked?
I mean, I create a plot as:
h = plot3(1:10,1:10,1:10,'o');
set(h,'ButtonDownFcn','my_callback.m');
Then the callback function accepts the inputs
function my_callback(src,event);
... but inside the body of this function I can only access the handle to the whole plot object (the src argument), which does not seem to contain information on which point was clicked onto to trigger the callback?
Is there a way around this? I know I could just assign a different callback to each point, but for thousands of points (as in my application) the performance slowdown is not acceptable.
Thansk! Daniel
0 件のコメント
回答 (1 件)
Image Analyst
2012 年 10 月 26 日
You can use ginput() to return the x,y coordinate of the point that was clicked. But you have to know that they are going to click and call ginput in preparation for that. If you're just sitting there idle and the user clicks on some image or axes, you may be able to rely on the mousedown event if you set one up. I haven't played around with that for getting x,y coords but it looks like it's possible from the help:
void MouseDown(int16 Button, int16 Shift, Variant x, Variant y)
参考
カテゴリ
Help Center および File Exchange で Specifying Target for Graphics Output についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!