How to make side-by-side bars with the histogram() function?
조회 수: 23 (최근 30일)
이전 댓글 표시
When using the now-discouraged hist function to make histograms comparing two data sets, the default display was to put the bars of the two histograms side-by-side.
Now, with the new histogram function, the default behavior is to superimpose the two distributions, with some transparency.
What's the easiest way to get the old side-by-side behavior, while still using the new function?
댓글 수: 0
답변 (1개)
Star Strider
2015년 5월 18일
편집: Star Strider
2015년 5월 18일
I doubt that’s possible without some serious hacking.
A work-around:
A = randn(100,2);
[h1,edges] = histcounts(A(:,1), 10);
[h2,edges] = histcounts(A(:,2), 10);
figure(1)
ctrs = edges(1)+(1:length(edges)-1).*diff(edges); % Create Centres
bar(ctrs, [h1 ;h2]')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!