Plot several seasonal NDVI time series data with marked transplanting time
조회 수: 2 (최근 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!
