I have a long time series, let's say of water level in a stream, shown on a line plot. I would like to shade in periods when a certain condition is true, let's say when it was raining. This shading would appear as light gray vertical blocks for every rainy time period, for example using the fill command. What do I need to add to the code below?
% Make fake time series of water level
t = 0:0.1:10; % Time
w = sin(2*pi*t); % Water level
% Make fake logical condition indicating when it's raining
iRain = false(size(t)); iRain([5:10 20 40:42 50 60:75 90:95]) = true; % Periods when it's raining, some very short
% Make line plot of water level
plot(t, w); hold on;f = fill(??); % Add vertical bars/blocks to indicate periods when iRain is true
Best Answer