How to shade area between standard deviations in a plot?
154 views (last 30 days)
Show older comments
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 18 Aug 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)).';
m = m(:); % [EDITED] Be sure that the data are column vectors
s = s(:); % [EDITED]
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.
More Answers (0)
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!