MATLAB: Graphing Many Plots and Data Analysis
2 views (last 30 days)
Show older comments
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 Comment
Vincent BARALE
on 25 Sep 2020
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
Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!