필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Ahmed
Ahmed 2024년 3월 3일
댓글: Voss 2024년 3월 3일
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()

채택된 답변

Voss
Voss 2024년 3월 3일
편집: Voss 2024년 3월 3일
% 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()

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by