using fill function to make shaded area

4 views (last 30 days)
Hi every one!
Is it possible to draw a shaded area (e.g., +- STD of a value) when we have a categorical values on x-axis?
Based on the screenshot I want AA,BB,CC instead of the numbers.(dash line is a value and the shaded area around it can be plus/minus STD)
Many thanks.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Nov 2022
x = categorical({'AA', 'BB', 'CC'});
yraw = rand(50,3);
ymean = mean(yraw,1);
plot(x, ymean, 'b');
s = std(yraw, [], 1);
hold on
fill([x, fliplr(x)], [ymean-s, fliplr(ymean+s)], 'k', 'FaceAlpha', 0.1 )
hold off
  4 Comments
Ham Man
Ham Man on 2 Nov 2022
Thank you so much Walter. That works.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!