How to shade time intervall
Mostra commenti meno recenti
I would like to shade specific time ranges(intervalls) which are created from a datamatrix in a for loop according to there indexes. I have the datetimes (begin and end of the intervall)
the Face (should be alpha = 0.2) and the y axis could be the whole plot domain or even better +- a certain mean value which I have as well.
goal is to have 5 different patches/areas on my timeseries
patch doesn't support datetime
fill/area etc. I couldn't find any satisfying solution
figure('DefaultAxesFontSize',15);
x = date;
y = CAL.stick_Data.stick_duty_cps;
k = 1; % placeholder in loop plot for row of CalibrationA(:,1)
idx=1;
for m= Markeridx'
hold all;
plot(x(:,k),y(:,m));
set(gca,'TickLabelInterpreter','latex')
set(gcf,'units','points','position',[100,100,700,500]) % figure position on screen and size is the saved figuresize!
caption = sprintf('y = %f * x + %f', p(1), p(2));
text(xt, yt, caption, 'FontSize', 12, 'Color', 'k', 'FontWeight', 'bold','interpreter','latex');
xlabel('ppbv ','interpreter','latex'); %FC_cal/FC_zeroair *1000
ylabel('cps','interpreter','latex');
idx = idx+1;
end
legend({'21.02264', '33.03350', '39.03321', '42.03382',...
'45.03350', '59.04914', '63.02629', '69.06988', '73.06480',...
'78.04640', '79.05422', '81.06988', '87.08045', '93.06988',...
'107.08553', '121.10118', '135.11683', '137.13248', '203.94361',...
'330.84809'})
a = axes;
t1 = title('Gas calibration dilution steps from subset A','interpreter','latex'); % Make sure to change titel after changing susbets
a.Visible = 'off'; % set(a,'Visible','off');
t1.Visible = 'on'; % set(t1,'Visible','on');
filter(1) = area([datetime(CALtime(1,3)) datetime(CALtime(1,end)) datetime(CALtime(1,end)) datetime(CALtime(1,3))],'FaceColor','r','Edgecolor','none', 'FaceAlpha',.3);
hold off;
Here is my figure without the shaded areas

Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Data Exploration in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
