"Unable to update data tip using custom update function"
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!