Cursor mode only for specified data
2 次查看(过去 30 天)
显示 更早的评论
Hello everybody,
I have one figure with two plots. One of them is a scatter plot and I want activate the data cursor and only find points of this data.
I dont know how to really modify using myfunction
Maybe creating a specific handle?
Thanks
Code:
function scatterMod(varargin)
scatter(varargin{:}) %this is the data which I want to work using the data cursor
dcm = datacursormode(gcf);
set(dcm, 'updatefcn', @myfunction)
function output_txt = myfunction(obj,event_obj)
% Display the position of the data cursor
% obj Currently not used (empty)
% event_obj Handle to event object
% output_txt Data cursor text string (string or cell array of strings).
pos = get(event_obj,'Position');
output_txt = {['X: ',num2str(pos(1),4)],...
['Y: ',num2str(pos(2),4)]};
% If there is a Z-coordinate in the position, display it as well
if length(pos) > 2
output_txt{end+1} = ['Z: ',num2str(pos(3),4)];
end
0 个评论
采纳的回答
Walter Roberson
2011-11-15
Try setting HitTest off on the points you do not want data cursor to work for. (I don't promise it will work, but it is worth the experiment.)
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!