Plot several seasonal NDVI time series data with marked transplanting time
1 次查看(过去 30 天)
显示 更早的评论
Dear all,
I have a time series NDVI data from 2014 to 2021 observed from October to March of next year as attached in the excel file. I want to plot 8 subplots vertically stacked corresponding to 8 years and for each year the transplating time will be highlighted with colors. There are two transplanting period for each year which were shown in the excel file. The idea is illustrated as the picture I modified by Paint. Please help me with this.
0 个评论
回答(1 个)
Star Strider
2023-3-11
I am not certain what you want to do with these data. I have no idea what ‘NDIV’ refers to.
This creates patch objects beginning with the date before each non-NaN value in ‘NDIV’ and extending to the next date in the series. I am guessing as to what you want, so you may need to change this to get the result you want, however it should get you started.
Try this —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1321105/Whole_periodNDVI_smo.xlsx', 'VariableNamingRule','preserve')
[G,ID] = findgroups(year(T1.('Time series')));
for k = 1:numel(ID)
Yrs{k,:} = T1(k==G,:);
end
figure
for k = 1:numel(Yrs)
% Yrs{k}
subplot(2,1,k)
v = find(~isnan(Yrs{k}.NDIV));
for k1 = 1:numel(v)
vidx = v(k1)+[-1;1];
xp = [Yrs{k}(vidx,:).('Time series'); flip(Yrs{k}(vidx,:).('Time series'))];
yp = reshape([ylim;ylim], [], 1);
hph = patch(xp, yp, 'r', 'DisplayName','NDIV', 'EdgeColor','r');
end
hold on
hpp = plot(Yrs{k}.('Time series'), Yrs{k}.Smoothed, 'DisplayName','Smoothed');
hold off
legend([hph(1),hpp], 'Location','bestoutside')
end
.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axes Appearance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!