Control long datetime xtick
1 次查看(过去 30 天)
显示 更早的评论
Hello. I have an array that starts from 2015 to the end of 2020 every 10 minutes. This is my x-axis. When I plot this the x-axis only shows years, but I would like to show every years and months. I attached the m_file. If you guys know how to do this or tell me some tips for controlling the x-axis, I would be really thankful.
0 个评论
采纳的回答
Walter Roberson
2021-4-17
编辑:Walter Roberson
2021-4-17
basedate = datetime(2015,1,1,0,0,0, 'Format', 'yy/MM');
enddate = datetime(2020,12,31,23,59,59, 'Format', 'yy/MM');
wanted_ticks = basedate + calmonths(0:(2020-2015+1)*12)
sample_dates = linspace(basedate, enddate, 30);
plot(sample_dates, rand(size(sample_dates)))
xticks(wanted_ticks)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!