How can I create a plot with quaterly dates on the x-axis ?
15 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
dpb
2016 年 1 月 3 日
編集済み: dpb
2016 年 1 月 3 日
dn=datenum(1973,1+[0:3:12*(2013-1973)].',1); % make a sample time vector
[datestr(dn(1)) '<->' datestr(dn(end))] % show what it spans
ans =
01-Jan-1973<->01-Jan-2013
plot(dn,randi(1000,size(dn))) % plot some dummy date over the range
datetick('x','QQ-YYYY') % format axes as time
xlim([dn(1) dn(end)]) % fit axes to range of actual data
You can adjust tick marks and format as desired; somewhat of a problem as the labels take up quite a lot of room but as demonstrated, the x-axis is plotted in date number range of floating point values and then transformed to display time by datetick
With the introduction of the new date/time data type, there's an overloaded plot function that handles that class of time inputs natively; I don't have the release so check the doc's...works generally the same way as the new class is also fundamentally a date number with just more resolution and builtin methods.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!