필터 지우기
필터 지우기

Change color of bar graphs?

조회 수: 1 (최근 30일)
Muhammad Tarique
Muhammad Tarique 2022년 7월 4일
답변: Chunru 2022년 7월 4일
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?

채택된 답변

Chunru
Chunru 2022년 7월 4일
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'})

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by