How to shade area between standard deviations in a plot?
114 views (last 30 days)
I would like to shade the area between standard deviations.
The data is attached. My code is as follows:
patch([mean(:); flipud(mean(:))], [mean(:)-sd(:); flipud(mean(:)+sd(:))], [0.6 0.7 0.8])
But it gives me this. Cold you please help?
Jan on 28 Mar 2022
Edited: Jan on 28 Mar 2022
data1 = load('mean.mat');
m = data1.mean;
data2 = loadt('std.mat');
s = data2.sd; % Do not use "mean" and "std" as variables!
x = (1:numel(m)).';
axes('NextPlot', 'add'); % as: hold on
patch([x; flip(x)], [m + s; flip(m - s)], [0.6 0.7 0.8])
Your code mixes x and y coordinates.