我有一个代码(如下),它绘制简单的 x、y 数据。我的时间(x 轴)最初是从 1 到 1257 的数字,对应于我正在查看的天数。我将其转换为序列日期以绘制它。但是,当它在 MATLAB 中绘制时,x 轴上没有足够的标签。当我尝试设置更多刻度线时,我要么以串行格式(我想要'mmm yyyy'格式)获得标签,要么当我尝试 NumTicks 时,我得到很多标签,但它们不正确,因为它们只是原始标签重复了几次。
% Find indexes at which the lat and lon match the conditions
lon_ind = find(X(:,1) == 224); % Longitude closest to 136 03.56W
lat_ind = find(Y(1,:) == -66.75); % Latitude closest to 66 39.67S
% Pull out all the data at the point 2240W and 66.75
data_point = data_All(lon_ind, lat_ind, :);
t = 1:1257; % Days 1:1257 inclusive. 20100101 to 20130611
y = reshape(data_point,[],1); % Change data_point into a 1 column matrix
x = datenum(2009, 12, 31) + t; % Convert t into serial numbers
% str = datestr(x, 'mmm yyyy'); % Choose format for x-axis
plot(x, y); % Plot data
datetick('x','mmm yyyy','keeplimits', 'keepticks'); % Set parameters
% NumTicks = 30;
% L = get(gca,'XLim');
% set(gca,'XTick',linspace(L(1),L(2),NumTicks))
set(gca,'XMinorTick','on','YMinorTick','on'); % Add minor ticks (without labels)
如何使 x 轴具有更多“mmm yyyy”格式的标签?