Bar charts with different colors
조회 수: 1 (최근 30일)
이전 댓글 표시
% Dear users, when I run the code I want to get bars in different colors (not one color). Could you please tell me how to do it?
% Thanks in advance!
SC01_LS02_TVSR_112=[0.0127 0.0139 0.0058 0.0112 0.0048 0.0126 0.0037];
bar(SC01_LS02_TVSR_112);
댓글 수: 0
답변 (2개)
Rik
2019년 11월 19일
Depending on your release you can set the CData property of every bar, or you will need to create separate bar objects and set the FaceColor property.
댓글 수: 0
KALYAN ACHARJYA
2019년 11월 19일
편집: KALYAN ACHARJYA
2019년 11월 19일
One way:
SC01_LS02_TVSR_112=[0.0127 0.0139 0.0058 0.0112 0.0048 0.0126 0.0037];
col=['r','y','b','k','b','k','y']; % Decide color as you want
for i=1:length(SC01_LS02_TVSR_112)
h=bar(i,SC01_LS02_TVSR_112(i));
set(h,'FaceColor',col(i));
hold on;
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Bar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!