Azzera filtri
Azzera filtri

Change color of bar graphs?

1 visualizzazione (ultimi 30 giorni)
Muhammad Tarique
Muhammad Tarique il 4 Lug 2022
Risposto: Chunru il 4 Lug 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?

Risposta accettata

Chunru
Chunru il 4 Lug 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'})

Più risposte (0)

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by