MATLAB Answers

How to set scientific notation in data tips ?

3 views (last 30 days)
andrea on 8 Nov 2020
Edited: Mario Malic on 9 Nov 2020
Hello ,
I would like to see scientific notation in the data tip on my plot , I attached an image of my plot , instead of that long number in the data tip I would like to have something like 77.5e13 is this possible ?
And also I want to change the scentific notation in the x axis, as you can see it displays 10^14 but I want it to be 10^13 .
Thank you.


Sign in to comment.

Accepted Answer

Mario Malic
Mario Malic on 9 Nov 2020
Edited: Mario Malic on 9 Nov 2020
x = 1:10
y = rand(1,10).*1000
h = plot(x,y)
for ii = 1 : length(x)
datatip(h, 'DataIndex', ii)
You can set format of each row in DataTip, by DataTipRows.Format.
dtTemplate = get(h, 'DataTipTemplate')
dtTemplate.DataTipRows(1).Format = '%e'; % adjust
dtTemplate.DataTipRows(2).Format = '%e';


Sign in to comment.

More Answers (1)

VBBV on 9 Nov 2020
h = plot(Intensity,velocity)
datatip(h,7.7E10,16.15); % h is handle to plot
xticklabels({'0','2E13','4E13','axis numbers...'})

  1 Comment

andrea on 9 Nov 2020
thank you, but I would like to change all the datatips at once, is there a way ?

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!