"Unable to update data tip using custom update function"
Show older comments
Hey guys, when I make the custom text function for dataCursorMode it keeps on showing this when clicking on the marker on the plot
Here is the code for the plot
function WinChampgraph_team_selector
data2 = readtable("alltimeteams.xlsx",'VariableNamingRule','preserve');
% Calculate the win percentage for each team
winPercent = (data2.Wins ./ (data2.Wins + data2.Losses));
hold on
graph = plot(winPercent, data2.Championships,"LineStyle","none","Color","r","Marker","*");
dcm = datacursormode;
dcm.Enable = 'on';
dcm.UpdateFcn = @displayteam;
getCursorInfo(dcm);
displayteam(data2);
xlabel('Win Percentage');
ylabel('Championships');
title('Team performance since the beginning of the NBA');
grid on;
set(gcf,'Position',[50,500,700,500])
end
Here is the code for the custom text function
function txt = displayteam(data3)
x = data3.Franchise;
y = (data3.Wins ./ (data3.Wins + data3.Losses));
myDatatipText = "(%s, %s, %s)";
txt = sprintf(myDatatipText, string(x), string(y),data3.Championships);
end
Then it shows this on the plot
Unable to update data tip using custom update function
Please lmk is anything else is needed
Accepted Answer
More Answers (0)
Categories
Find more on Line Plots 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!