Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
Ahmed
Ahmed le 3 Mar 2024
Commenté : Voss le 3 Mar 2024
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()

Réponse acceptée

Voss
Voss le 3 Mar 2024
Modifié(e) : Voss le 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()
  2 commentaires
Ahmed
Ahmed le 3 Mar 2024
@Voss Thanks
Voss
Voss le 3 Mar 2024
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by