present 2 histograms in the same X axis values
조회 수: 13 (최근 30일)
이전 댓글 표시
Hi,
I'm trying to plot 2 histograms in the same x axis. they suppose to have common peaks and I'd like to present them at the same scale so the peaks will overlap. is theres a way to do it?
this is the result I want to achive, but in here I used histcount and it made some other troubles.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/279510/image.jpeg)
댓글 수: 5
답변 (1개)
sani
2020년 3월 26일
편집: Adam Danz
2020년 3월 27일
댓글 수: 6
Akira Agata
2020년 3월 27일
편집: Akira Agata
2020년 3월 27일
It's not clear for me what should be done.
Previously, you said that "need both of the histograms to contain the same number of bins and that the peaks but when I wried to set the bins number I got a mess". So I adjusted edge resolution ( = bin width) and (I think) achieved "both of the histograms to contain the same number of bins" avoiding to "got a mess (figure)".
Or, you mean you want plot only details of the histogram around Energy of ~500 [keV] ?
Adam Danz
2020년 3월 27일
I'm also struggling a bit to understand the end goal but from what I understand, you have two data sets, one with n values and the other with m values (n ~= m) and you'd like the histogram bins to match. Is that correct?
If so, try this:
combinedData = [data1(:); data2(:)];
edges = linspace(min(combinedData), max(combinedData), 20); % the 20 is the number of bins
histogram(data1, edges);
hold on
histogram(data2, edges);
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!