datatip gives same x value for different samples
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Paul Hoffrichter
am 6 Dez. 2022
Kommentiert: Paul Hoffrichter
am 6 Dez. 2022
Here is a simplified example of my problem. How can I get tooltips to show X 500000, X 500001, X 500002, etc.? Instead it shows X 500000 for all of these points. When the number of points is large enough, tooltips does not give correct integer sample number.
x = 1:1e6; % sample number
y = (-1).^x;
plot( y,'.' ); ylim( [-1.5 1.5]); xlim([500000 500020]);
title('R2020a: Tooltip shows X 500000 for all the points')
0 Kommentare
Akzeptierte Antwort
Mario Malic
am 6 Dez. 2022
Bearbeitet: Mario Malic
am 6 Dez. 2022
Hey Paul,
I am using the R2021b and I see the datatips properly, but you can play with the last two lines to get your desired output.
x = 1:1e6; % sample number
y = (-1).^x;
lineHandle = plot( y,'.' ); ylim( [-1.5 1.5]); xlim([500000 500020]);
title('R2020a: Tooltip shows X 500000 for all the points')
dt = datatip(lineHandle, 500010, 1);
% You can play with format specification to get the desired output
lineHandle.DataTipTemplate.DataTipRows(1).Format = '%6d';
lineHandle.DataTipTemplate.DataTipRows(2).Format = '%6d';
% lineHandle.DataTipTemplate.DataTipRows.Format is a comma separated list,
% I never remember how to assign to it
4 Kommentare
Mario Malic
am 6 Dez. 2022
It has a different name in R2020a: https://www.mathworks.com/help/releases/R2020a/matlab/ref/matlab.graphics.datatip.datatiptextrow.html
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!