필터 지우기
필터 지우기

Bar plot with different color and tick label for each bar

조회 수: 3 (최근 30일)
mitilma
mitilma 2013년 11월 14일
Hi,
What I expect below code to output is 4 different bars in a bar plot each with different colors, and with tick labels 'a', 'b', 'c', and 'd' respectively. Colors are fine, but only the first bar has the label 'a', the other three have no labels. How can I achieve tick labeling bars in the bar plot while highlighting them with different colors? I am using version 2010b. Thanks!
deneme = [1 2 3 4];
figure;
for i=1:length(deneme)
if i==1
colorcode = 'b';
elseif i==2
colorcode = 'g';
elseif i==3
colorcode = 'r';
else
colorcode = 'k';
end
bar(i, deneme(i), colorcode);
hold on;
end
set(gca,'XTickLabel',{'a'; 'b'; 'c'; 'd'})

답변 (0개)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by