Shade some region in histogram...????

2 views (last 30 days)
Shoaib Kalsekar
Shoaib Kalsekar on 3 Mar 2013
Suppose i have an 1-D array X and I plot the histogram. Now i want to do two things... 1>> I want to mark on the same histogram, with a vertical line, the mean of the array X... 2>> I want to shade some regions (lets say from mean-std to mean+std) in the same histogram... (the second point is really tricky nd needs some serious help..)

Answers (1)

Image Analyst
Image Analyst on 3 Mar 2013
Use line() and ylim() to plot a vertical line at the desired xMean value:
yl = ylim;
hold on;
line([xMean, xMean], [yl(1), yl(2)], 'LineWidth', 3);
Use patch() or fill() to create shaded/filled rectangles on the plot. Or you could just plot a second histogram on top of the first one if you want certain bars to be a different color.

Tags

Community Treasure Hunt

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

Start Hunting!