Plotting date (number) on x-axis
이전 댓글 표시
I want to plot all the day numbers on x-axis. I have really big timeseries data with 10-min wind speed averages, starting from 1st April and ending 30th April. I want to plot the wind speed, measured every 10min during the day, for the whole month. And on the x-axis I want to have ticks for every day starting from 1 till 30. Here is the code:
%% direct timetable importing
clc
clear
load april.mat %april timetable
dnum = day(ex1.timestamp);
mnum = month(ex1.timestamp);
myear = year(ex1.timestamp);
myear = unique(myear); %finding year
mnum = unique(mnum); %fingind month number
dlast = unique(max(dnum)); %finding last day
duniq = unique(dnum);
duniq = num2cell(duniq);
plot(ex1.timestamp,ex1.CH1Avg)
hAx = gca;
xlim(datetime([myear myear],[mnum mnum],[1 dlast])); %setting limits
xticklabels(duniq); %setting ticks to 30 like the number of days in April
datetick('x','dd'); %using date ticks, not working when trying dd
When i use in datetick('x','d') it is working. But when i use datetick('x' ,'dd') -it is not working. I also tried with datetick('x','d','keepticks'), but not working properly.
Can someone please help me?
Like it is shown on screenshot I want on x axis to have evenly distributed ticks for every day, starting from 01,02... ending at 30. like it is set in xlim
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!