How can I create a plot with quaterly dates on the x-axis ?
조회 수: 14 (최근 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!