Effacer les filtres
Effacer les filtres

Change color of bar graphs?

1 vue (au cours des 30 derniers jours)
Muhammad Tarique
Muhammad Tarique le 4 Juil 2022
Réponse apportée : Chunru le 4 Juil 2022
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?

Réponse acceptée

Chunru
Chunru le 4 Juil 2022
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'})

Plus de réponses (0)

Catégories

En savoir plus sur Discrete Data Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by