MATLAB Answers

Invert a histogram by emphasizing on the valleys

조회 수: 4(최근 30일)
kathsb 2021년 8월 20일
댓글: Steven Lord 2021년 8월 20일
Hello! I have a regular histogram, where I have my peaks at a certain frequencies. However, i want to emphasize on the valleys in my histogram rather than on the peaks. How do I make it so? I want my new histogram to display the peaks as the spaces with the biggest valleys in the initial plot. Like invert it, in a sense?
  댓글 수: 7
kathsb 2021년 8월 20일
@Image Analyst I have removed the picture after i accepted the answer due to personal reasons. The reason I'm looking for this kind of interpretation is just purely for scientific analysis and the result wouldn't be misleading in this particular case. Now regarding my last comment, I was simply just trying to be polite and thank the contributor for their help.

댓글을 달려면 로그인하십시오.

채택된 답변

Yazan 2021년 8월 20일
편집: Yazan 2021년 8월 20일
One way to do that probably is by subtracting the rate in each bin from the maximum rate. Below is an example with normal distribution. I'm not sure though if interpreting this result is very meaningful.
clc, clear
x = randn(1, 1000);
h1 = histcounts(x);
h2 = max(h1)-h1;
bar(h1, 'FaceAlpha', 0.5), hold on, bar(h2, 'r', 'FaceAlpha', 0.5);
  댓글 수: 2
Steven Lord
Steven Lord 2021년 8월 20일
Instead of using bar you could use the output from histcounts as the BinEdges and BinCounts in a call to histogram.
x = randn(1, 1e5);
[counts, edges] = histcounts(x);
histogram('BinEdges', edges, 'BinCounts', max(counts)-counts)

댓글을 달려면 로그인하십시오.

추가 답변(0개)




Community Treasure Hunt

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

Start Hunting!

Translated by