how to set x axis into hours

Illustration
ishitaisha6840 - 2020-09-02T11:37:44+00:00
Question: how to set x axis into hours

i have problem . how to i set the x axis into hour. i have 10080 data and each one represents one minute of data. i want to represents x axis with 24 hour, how can I make like that

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

xtickat = 0:60:length(YourData)-1;  %every hour from 00:00
set(gca, 'XTick', xtickat, 'XTickLabel', cellstr( num2str( mod(round(xtickat .' ./ 60),24) ) ) )
This will use hour 0, 1, 2, ... 23, 0, 1, 2, ... 23, and so on, with no indication of the day of the week (as the question asked for x axis to be in 24 hour, not for day and hour)
 
This will try to produce 168 ticks, which might perhaps be too much for your purposes. If so you can increase the 60 in xtickat to a more appropriate number such as 360 (6 hours).


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!