change y values in figure to names
Show older comments
I was able to plot temperatures of each hour in the year and got this result using this command:
plot(A(1:8760,5)')

X axis is the hours of the year
Y axis is the temperature vaule of each day
Question:
How can I change the crosses values in X axis to be the months names rather than hours?
i.e.
January instead of 1000
Febraruy instead of 2000
and so on
Accepted Answer
More Answers (1)
Hello
In your question you said y but it seems you mean x; anyways,
Try this:
names = {'January'; 'February'; 'March'; 'April'; 'May'; 'June'; 'July'; 'August'; 'September';...
'October'; 'November'; 'December'};
set(gca,'xtick',[1:12],'xticklabel',names)
But:
You have 10 month ?
So you end in october? so this is:
names = {'January'; 'February'; 'March'; 'April'; 'May'; 'June'; 'July'; 'August'; 'September';...
'October'};
set(gca,'xtick',[1:12],'xticklabel',names)
I hope it helps you.
2 Comments
HG-NU
on 7 May 2020
Try this:
set(gca,'xtick',1:10,...
'xticklabel',{'January'; 'February'; 'March'; 'April'; 'May'; 'June'; 'July';...
'August'; 'September'; 'October'})
% if you have 12 months change 10 to 12 and also type name of othee months
I think previous code not worked because of "[]"
Categories
Find more on Timetables 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!


