How to change x-axis values?
Show older comments
Hello guys,
Matlab automatically put the x-axis values into x10 format. For example 1.96 x10^7 instead of 1996. This is wrong.
How can I make x-axis values to look like whole number values i.e. 1996, 1998 etc?
Thank you.
Answers (1)
Daniel Pollard
on 15 Dec 2020
This was the top result when I googled "matlab remove scientific notation axis".
From R2015b onwards,
ax = gca;
ax.XRuler.Exponent = 0;
14 Comments
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Daniel Pollard
on 15 Dec 2020
In your post you said that the numbers show 1.96x10^7 instead of 1996. If these are years, then there's a problem with your dataset as 1.96x10^7 = 1,960,000, not 1996.
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Daniel Pollard
on 15 Dec 2020
No, it will be 1960 x10^4, but I think that's ok looking at your data as the temperature seems to oscillate 20 times between 1.96 and 1.98. A quick and dirty fix would be to divide the numbers by 1000, is there any reason you shouldn't do that?
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Daniel Pollard
on 15 Dec 2020
There's some bizzare things going on there. Why do you divide the date_data by 10000 as you import it? You then overwrite the xlim with 1:length(years), then relabel it with the date_data, manually doing what would have been automatic.
Why not just import the date_data and temperature_data and plot them against each other?
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
Daniel Pollard
on 15 Dec 2020
That is strange and suggests that it's an issue with those particular data. Maybe someone else in your class or a professor can help more as they have the data and understand better than me.
Catayoun Lissa Eleonore Azarm
on 15 Dec 2020
You have to apply same to
%
subplot(5,3,1)
subplot(5,3,6)
subplot(5,3,11)
Categories
Find more on Graphics Performance 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!
