format the y tick labels

1 view (last 30 days)
Seldeeno
Seldeeno on 6 May 2014
Commented: Seldeeno on 9 May 2014
hello,
How can I format the y tick labels in e-notation? (note: I entered those exact labels as numbers in the form I want them to appear) but I still want them to appear in e-notation. Is there a way to do this when I edit the figure properties?
Thanks

Accepted Answer

Sara
Sara on 6 May 2014
If you want to change the format of the y-axis:
y = get(gca,'ytick');
yy = cell(numel(y),1);
for i = 1:numel(y)
yy{i}=sprintf('%10.3e',y(i)); %%CHOOSE PRECISION
end
set(gca,'yticklabel',yy)
  16 Comments
Sara
Sara on 9 May 2014
It's the:
'horiz', 'left'
command, try taking it away. Note, you may want to do:
set(gca,'fontsize',8)
so that all the ticks are of the same size.
Seldeeno
Seldeeno on 9 May 2014
Sara, you are great. Thank you for your help :)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!