Plot several time series data stacked in one graph
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Dear all,
I have the dynamic area data for 7 years from 2016 to 2022 as attached in the excel file. I want to plot 7 line of data with x axis is the date from 01/01 to 31/12 (year excluded) and  y axis is the area value but I do not know how to plot with only day and month. Then I want to add a legend to distinguish 7 years. Can you help me with this please!  
0 Commenti
Risposta accettata
  Star Strider
      
      
 il 5 Mar 2023
        
      Modificato: Star Strider
      
      
 il 5 Mar 2023
  
      Try this — 
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1314900/Data.xlsx')
VN = T1.Properties.VariableNames;
DateMtx = T1{:,1:2:end};
for k = 1:size(DateMtx,2)
    [y,m,d] = ymd(DateMtx(:,k));
    MDdt(:,k) = datetime(1,m,d);
end
figure
hold on
for k = 1:size(MDdt,2)
    plot(MDdt(:,k), T1{:,2*k}, 'DisplayName',strrep(VN{2*k},'_','\_'))
end
grid
xtickformat('dd/MM')
legend('Location','best')
xlabel('dd/MM')
ylabel('Area')
EDIT — (5 Mar 2023 at 17:38)
Corrected typographical error (specifically so that xticklabel correctly matches xtickformat).  Code unchanged.  
.
2 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Dates and Time in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


