How to highlight part of a Histogram Plot based on a threshold value
5 views (last 30 days)
Show older comments
If I am plotting data using:
H=histogram(DATA,5,'Normalization','pdf');
For simplicity lets say
DATA=1:10;
And want to highlight all values on the histogram plot using a threshold (i.e. highlight all values less than or equal to 4)
How would I accomplish this?
Thank you in advance.
0 Comments
Answers (1)
KSSV
on 27 Oct 2017
data = randperm(20,10) ;
figure
hold on
for i=1:length(data)
h = bar(i, data(i));
if data(i) <=10
col = 'r';
else
col = 'b';
end
set(h, 'FaceColor', col)
end
1 Comment
Ronnie Abolafia-Rosenzweig
on 27 Oct 2017
Thank you for the reply; however I am looking to keep my chart in histogram format and only highlight the area of the graph below a minimum threshold. If there is a bin with a bind edge from 0.2 to 0.3, and my threshold is 0.25, I would only like to highlight half of this bin along with all other bins with lesser values
See Also
Categories
Find more on Histograms 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!