Combining and Visualizing two histograms

조회 수: 18(최근 30일)
Hi,
I am having histogram plot of (x,y) =(15, 1000), this belongs to one class. And also I am having histogram plot of (x,y) = (15, 1500) of another class. (here, x axis same, but y axis different). I need to combine these two plots in a single plot separating each class. How can I do that? Pease help me with this. Thanks in advance.
  댓글 수: 1
Debadipto
Debadipto 2022년 7월 12일
Can you share the code you've written so far?

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

채택된 답변

Abderrahim. B
Abderrahim. B 2022년 7월 12일
편집: Abderrahim. B 2022년 7월 12일
Hi!
Use hold on, will be displayed in 2 different colors.
Example 1:
x = randi(10,20,1) ;
y = randi(10,20,1) ;
histogram(x);
hold on
histogram(y);
Example 2:
Use bar function
figure
bar([x, y], 'stacked')
legend x y
  댓글 수: 2
Abderrahim. B
Abderrahim. B 2022년 7월 12일
편집: Abderrahim. B 2022년 7월 12일
I edited my answer. Check it and let me know if this is what you are trying to do!

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

추가 답변(0개)

범주

Find more on 2-D and 3-D Plots 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!

Translated by