Time format printing too much
2 ビュー (過去 30 日間)
古いコメントを表示
I want to label the time axis in a plot with "ddd: HH" (speak "first three letters of the day, then the two digits for the hour in 24-hour format).
However, when doing this, the format is applied for some labels, but otheres also print more information like month, day and year.
% generate time sequence, last 3 days, 12 hours offset
xtickformat('eee: HH')
t2 = datetime('today'),
t1 = t2-days(3)
xData = t1:hours(12):t2
set(gca,'xtick',xData)
Leads to:
0 件のコメント
採用された回答
dpb
2019 年 9 月 21 日
編集済み: dpb
2019 年 9 月 21 日
I presume your complaint is the range label automagically shown for datetime axes. Seems there should be a way for user to turn that on/off, but doesn't appear to be...
The following generates
t2 = datetime('today');
t1 = t2-days(3);
xData = t1:hours(12):t2;
hL=plot(xData,randn(size(xData)));
xticks(xData)
xtickformat('eee: HH')
hAx=gca; % get current axes handle
hXAx=hAx.XAxis; % retrieve handle to xaxis datetime ruler object
hXAx.SecondaryLabel.String=''; % set the limits label string to empty
The SecondaryLabel property is hidden one -- used the FEX submission of Yair Altman to discover the name of the nondisclosed properties.
NB: Until the axes is created as a datetime ruler object, xtickformat will fail as will xticks as default requires double. At least thru R2017b here--perhaps later releases will automagically convert the axis type as needed; can't test that here but I'd be somewhat surprised.
その他の回答 (0 件)
コミュニティ
その他の回答 ThingSpeak コミュニティ
参考
カテゴリ
Help Center および File Exchange で Visualize Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!