set the tick format of y axis
Show older comments
How can I set the format of the ticks of the y axis?
I want to change the upper one to the lower one, as the former is too wide in space.

1 Comment
dat = 0.008*rand(1, 5); % Sample random data
plot(dat)
ylim([0 0.008]) % Set any arbitrary limit
Here's a compact plot, with suitable limits:
plot(dat)
ylim([min(dat) max(dat)]) % Set compact limits
Accepted Answer
More Answers (3)
Voss
on 7 Oct 2024
0 votes
set(gca().YAxis,'Exponent',-3)
Walter Roberson
on 7 Oct 2024
0 votes
See ytickformat and also the Exponent property of axes; https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html#SpecifyAxisTickValuesAndLabelsExample-5
You can achieve the desired xtick format in MATLAB. In order to demonstrate this consider the code:
% Here, I will demonstrate how to express the xticks and yticks in exponent form.
x=100:100:2000;
y=100:100:2000;
plot(x,y)
ax = gca;
ax.XAxis.Exponent = 2;
ax.YAxis.Exponent = 2;
You can refer to the following link to get more information:
I hope it helps!
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



