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

28 ビュー (過去 30 日間)
yousra boukaissi
yousra boukaissi 2022 年 6 月 6 日
コメント済み: Bjorn Gustavsson 2022 年 6 月 7 日
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
Bjorn Gustavsson
Bjorn Gustavsson 2022 年 6 月 7 日
Great, happy that it helped.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by