Azzera filtri
Azzera filtri

How to adjust color of each bar in a grouped bar plot?

1 visualizzazione (ultimi 30 giorni)
Following is my code, two bars in each group of bars, I want to fix the colors e.g., blue and yellow of two bars in each gropu. How I can chnage this code? FT in blue and AK in yellow?
data = [F_CRPS_ip A_CRPS_ip; F_CRPS_is A_CRPS_is; F_CRPS_rho A_CRPS_rho];
y = data;
x = ["I_P" "I_S" "Rho"];
figure(); b = bar(x,y);
xlabel('Predictions');
ylabel('Mean CRPS');
set(b, {'DisplayName'}, {'FT','AK'}');
legend()

Risposta accettata

Voss
Voss il 3 Mar 2024
Modificato: Voss il 3 Mar 2024
% data = [F_CRPS_ip A_CRPS_ip; F_CRPS_is A_CRPS_is; F_CRPS_rho A_CRPS_rho];
data = rand(3,2);
y = data;
x = ["I_P" "I_S" "Rho"];
figure();
b = bar(x,y);
b(1).FaceColor = [0 0 1]; % RGB blue
b(2).FaceColor = [1 1 0]; % RGB yellow
xlabel('Predictions');
ylabel('Mean CRPS');
set(b, {'DisplayName'}, {'FT','AK'}');
legend()

Più risposte (0)

Categorie

Scopri di più su Data Distribution 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