我在Matlab中有以下散点图:
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
scatter(x,y)
用户现在应该能够点击散点图中的圆圈。如何识别用户点击的圈子(即(x,y)值)?
答案 0 :(得分:2)
在回调函数中,您可以使用axis对象的CurrentPoint属性来获取(x,y)位置:
loc = get(gca, 'CurrentPoint'); % or use dot notation for later Matlab
loc = loc(1, 1:2); % most of the time we are interested in front xy