Mean and Std in Subplot Graphs
2 views (last 30 days)
Show older comments
How can i add mean and Std horizontal lines to all plots?? (eg.ym1 and ys1 are mean and std of subplot subplot(3, 2, 1))
figure
subplot(3, 2, 1)
ym1=mean(distlocus1)
ys1=std(distlocus1)
plot(distlocus1)
title('Início - 15''')
subplot(3, 2, 2)
ym2=mean(distlocus2)
ys2=std(distlocus2)
plot(distlocus2)
title('15'' - 30''')
subplot(3, 2, 3)
ym3=mean(distlocus3)
ys3=std(distlocus3)
plot(distlocus3)
title('30'' - Intervalo''')
subplot(3, 2, 4)
ym4=mean(distlocus4)
ys4=std(distlocus4)
plot(distlocus4)
title('Intervalo'' - 60''')
subplot(3, 2, 5)
ym5=mean(distlocus5)
ys5=std(distlocus5)
plot(distlocus5)
title('60'' - 75''')
subplot(3, 2, 6)
ym6=mean(distlocus6)
ys6=std(distlocus6)
plot(distlocus6*ym6)
title('75'' - Final''')
0 Comments
Answers (1)
Star Strider
on 17 Sep 2017
Edited: Star Strider
on 17 Sep 2017
I would plot them as:
plot(xlim, [1 1]*ym1, '-r', xlim, ym1+[1 -1; 1 -1]*ys1, '-g')
and so for the others.
This plots the mean in red, and the the two standard deviation lines in green. This uses xlim, so it will automatically span the x-axis limits.
2 Comments
Star Strider
on 17 Sep 2017
I was thinking of something like this:
subplot(3, 2, 1)
ym1=mean(distlocus1)
ys1=std(distlocus1)
plot(distlocus1)
hold on
plot(xlim, [1 1]*ym1, '-r', xlim, ym1+[1 -1; 1 -1]*ys1, '-g')
hold off
title('Início - 15''')
So add the hold calls, and the new plot call, to plot the mean and standard deviation. This applies to all the subplots, so all you need to do is to change ‘ym1’ and ‘ys1’ in the other subplots to their appropriate variables.
See Also
Categories
Find more on 2-D and 3-D Plots 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!