MATLAB: Curve distorted with time

timetime series

Hello all I am trying to plot data from the attached test.mat file. If I just plot the data alone using the command plot(raw_summer_0mean), I got a nice curve shown below, but when I plot it with the time(attached below) , the curve is distorted. Any suggestions. Thanks in advance.
raw_summer_0mean=raw_summer-mean(raw_summer);
figure;plot(x_data_summer,raw_summer_0mean)
line([1 length(raw_summer_0mean)],[std(raw_summer_0mean) std(raw_summer_0mean)],'Color','r','LineWidth',1,'LineStyle','--')
line([1 length(raw_summer_0mean)],-[std(raw_summer_0mean) std(raw_summer_0mean)],'Color','r','LineWidth',1,'LineStyle','--')
text(x_data_summer(3),std(raw_summer_0mean)+1,['\sigma ',num2str(std(raw_summer_0mean))])
xlabel('Time')
ylabel('Precipitation Raw')
axis([min(x_data_summer) max(x_data_summer) min(raw_summer_0mean) max(raw_summer_0mean) ])
set(gca,'XTick',x_data_summer(1):diff(x_data_summer):x_data_summer(length(x_data_summer)))
datetick('x','yyyymmm','keeplimits', 'keepticks')
rotateXlabels(gca,90)

Best Answer

Your time vector x_data_summer is not evenly spaced. When you only plot the raw_summer_0mean data, Matlab is assuming the x axis is evenly spaced. But your date numbers skip the winters.