Patch function doesnt shade the second plot.
Show older comments
Hello, I am trying to plot 2 datasets on the same plot. I have 2 data sets that contain of means and standard deviations. I want to plot them so that the mean is plotted as a line plot and the standard deviation is plotted as a shaded area around it. I am using the patch function and i am able to get this done for one data set but when i try to do it for the second data set, the patch function doesnt shade in the area between the standard deviation, rather it just plots the standard deviation as 2 lines.
This is the code I am using.
plot(time,meanND);
hold on;
patch([time fliplr(time)], [meanND-stdev fliplr(meanND+stdev)], 'r', 'FaceAlpha',0.2, 'EdgeColor','none');
hold on;
plot(time, meanNDtest);
hold on;
patch([time fliplr(time)], [meanNDtest-stdevtest fliplr(meanNDtest+stdevtest)], 'r', 'FaceAlpha',0.2, 'EdgeColor','r');
hold off

I dont understand what I am doing wrong. Any help will be appreciated. I tried changing the patch arguments for the second plot. Nothing changes the shaded region. I am only able to change the opacity of the standard deviation lines.
Accepted Answer
More Answers (0)
Categories
Find more on Annotations 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!
