Clear Filters
Clear Filters

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

1 view (last 30 days)
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()

Accepted Answer

Voss
Voss on 3 Mar 2024
Edited: Voss on 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()

More Answers (0)

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!