필터 지우기
필터 지우기

Stacking two sets of data in a histogram

조회 수: 18 (최근 30일)
jgillis16
jgillis16 2015년 7월 25일
답변: Star Strider 2015년 7월 25일
I need to stack two arrays of equal size, 1x100 double, in a histogram. The problem is that I can individually show two different histograms in a single plot, but I want to combine data into one histogram so that the bars of the histogram are 'stacked' and form a 'visual ratio'. I have attached a sample histogram of what I want visually.
Any help would be really appreciated!

채택된 답변

Star Strider
Star Strider 2015년 7월 25일
You need to express them as column vectors, then concatenate them into a single array to use bar with the 'stacked' option:
A = randi(25, 1, 100);
B = randi(50, 1, 100);
figure(1)
bar([A(:) B(:)], 'Stacked')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by