How can I get the datatip to display its tag?

조회 수: 1 (최근 30일)
Andrew Dabrowski
Andrew Dabrowski 2020년 5월 13일
답변: Shantanu Thatte 2021년 6월 25일
I've tried
output_txt = {[event_obj.Target.Tag]};
but frustratingly, Target gets the whole image rather than the datatip.

채택된 답변

Shantanu Thatte
Shantanu Thatte 2021년 6월 25일
Hi Andrew,
It seems like you are trying to show the Tag of the target object in the data tip. One possible solution is to customize DataTipTemplate property of the chart object. Here is an example:
l = plot(1:10,"Tag","I am tag");
% Customize the content of data tip
l.DataTipTemplate.DataTipRows = dataTipTextRow("Tag",repmat(string(l.Tag),numel(l.XData),1));
% Create data tip at index 2 or click to create data tip interactively
d = datatip(l,"DataIndex",2)
You can refer to Create Custom DataTips documentation for more details.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by