フィルターのクリア

Change color of bar graphs?

1 回表示 (過去 30 日間)
Muhammad Tarique
Muhammad Tarique 2022 年 7 月 4 日
回答済み: Chunru 2022 年 7 月 4 日
so I am using following code for my bar graph
y = [0.1064 0.1069 0.1084 0.1113 0 0.1130 0.1165 0.1189 0.1217];
barh(y)
yticklabels({'rbio3.5','rbio3.7','rbio3.9','rbio3.3','-','bior3.5','rbio1.3','rbio2.8','db4'})
and I am getting this result but what I want is to change color of last 4 bars how can i do so?

採用された回答

Chunru
Chunru 2022 年 7 月 4 日
y = [0.1064 0.1069 0.1084 0.1113 0 0.1130 0.1165 0.1189 0.1217];
b = barh(y);
b.FaceColor = 'flat';
b.CData(1:4, :) = repmat([1 0 0], [4 1]); % [1 0 0] for red
yticklabels({'rbio3.5','rbio3.7','rbio3.9','rbio3.3','-','bior3.5','rbio1.3','rbio2.8','db4'})

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by