How to plot data only certain days of a year.
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
KSSV
on 6 May 2021
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))
See Also
Categories
Find more on Dates and Time 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!