MATLAB: Graphing Many Plots and Data Analysis
2 次查看(过去 30 天)
显示 更早的评论
My question is about plotting many sets of x-y data in one plot. I want to know how I can make it so that if I select one point on the plot, it will tell me which plot is being selected at the same time it tells the x and y data. I figured out how to create a Callback function that can change the datatip of the plot to display this information (which I will paste below), but I don't know how to change the Text Update Function in an m-file instead of right clicking on the plot and selecting "select Text Update Function" and selecting the function Thanks. Sarah C.
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'); I = get(event_obj, 'DataIndex');
output_txt = {['X: ',num2str(pos(1),4)],... ['Y: ',num2str(pos(2),4)],... ['legend: ', event_obj.Target.DisplayName],['I: ',num2str(I)]} % 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
1 个评论
Vincent BARALE
2020-9-25
Hello, I have the same question and still don't find answer.
Maybe this post may help you, but I dif'n find the script in my files
Vincent
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!