How to change the colours of bars in a histogram with multiple data

조회 수: 28 (최근 30일)
I have two Data sets re_hight and re_low. I made a distribution of both sets withing the same diagram. How can i chage the default colours to red and blue?
the code for the plot is:
hist([re_low re_high],[-2:2:182]);
xlim([-2 82]);

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2022년 6월 6일
If you take the output from hist and plot that with bar, you can do something like this:
[phH1,phH2] = hist([re_low' re_high'],[-2:2:182]);
bh = bar(phH2,phH1);
set(bh(1),'FaceColor','b')
set(bh(2),'FaceColor','r')
HTH
  댓글 수: 2
yousra boukaissi
yousra boukaissi 2022년 6월 6일
편집: yousra boukaissi 2022년 6월 6일
Thanks a lot it worked!!! i really appreciate it

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

추가 답변 (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