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!