How to plot data only certain days of a year.
5 次查看(过去 30 天)
显示 更早的评论
How to plot or bar data for only certain days of the year. X axis will 365 days Y axis will have cyclist
Eg if the year has 365 days and Jan has cyclist data for day 10, day 12 and day 14 of that month.
Feb has cyclist data for day 1,3,7,8,10,12,14 for that month March has cyclist data for day 12, 15,20,22, 23, 24, 25, 27 for that month.. And so on... How to I get to plot these EXACT days of the month on the x axis without data for other days of the months and year? I want to keep each months data under their assigned month but still show if it’s day 2 or 11 etc I want all this data on 1 graph as I said with y axis being cyclist and x axis being days each month
0 个评论
回答(1 个)
KSSV
2021-5-6
You may proceed something like below:
t = datetime(2020,1,1):datetime(2020,12,31) ;
y = rand(size(t)) ; % random y-axis values for demo
% make required dates to plot
jan_t = datetime(2020,1,[10 12 14]) ;
feb_t = datetime(2020,2,[1,3,7,8,10,12,14]) ;
mar_t = datetime(2020,3,[12, 15,20,22, 23, 24, 25, 27]) ;
ti = [jan_t feb_t mar_t] ;
% plot
[idx,ia] = ismember(t,ti) ;
plot(ti,y(idx))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!