爲了最大程度的控制,你可以自己動手完成它:
% Plot data
hours = linspace(0, 2, 6000); % time base for plot
data = randn(size(hours)); % data for plot
plot(hours, data)
% Compute tick positions
tickPos = min(hours) : 0.25 : max(hours); % every quarter hour from start to finish
timeZero = datenum(2015, 01, 09, 08, 00, 00); % measure from 8:00 this morning
timeStamps = timeZero + tickPos/24; % datenum returns a value in units of days, so divide tickPos by 24 to convert from hours to days
timeStampStrings = cellstr(datestr(timeStamps, 'HH:MM')); % or whatever format seems best
set(gca, 'xlim', hours([ 1 end ]), 'xtick', tickPos, 'xticklabel', timeStampStrings)
...但使用datetick
正確的方法是,以確保該地塊的x軸是datenum
單位:
plot(timeZero + hours/24, data)
datetick('x', 'HH:MM')
來源
2015-01-09 21:14:03
jez