Cannot add shaded confidence intervals?
Show older comments
Hello all,
I have a graph with confidence intervals, where I want to make it so that the confidence intervals are shaded between both of them. I have the following code:
% 1) getting confidence intervals
[ci_groups, ci_pre, ci_post]=bootstrapping_function(matrix_mean, matrix_post_mean)
% 2) taking confidence intervals and multipling by size of matrix
ci_lower_pre = ci_pre(1)*ones(size(matrix_mean));
ci_higher_pre = ci_pre(2)*ones(size(matrix_mean));
% 3) making figure
figure;
plot(f_mr,matrix_mean, '-b'); hold on
% 4) fill the area between the confidence intervals
x = [f_mr, fliplr(f_mr)];
y = [matrix_mean + ci_higher_pre, fliplr(matrix_mean - ci_lower_pre)];
fill(x, y, 'r', 'FaceAlpha', 0.5, 'EdgeColor', 'none');
But when I use the code above I get the attached 'example' as my figure, where there is shading outside of the confidence intervals. Do you have any advice?
Thanks a ton
Accepted Answer
More Answers (0)
Categories
Find more on Surfaces, Volumes, and Polygons 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!
