Change Colors of bar chart

조회 수: 5 (최근 30일)
Tiago Dias
Tiago Dias 2019년 6월 4일
답변: dpb 2019년 6월 4일
Hello,
I got a fig.file which is a bar chart (attached). And I want to change some bar charts to red for example, bar 4, 10 and 15. but i get an error on the 'flat' line.
Unrecognized property 'FaceColor' for class 'matlab.ui.Figure'.
Error in sadadadadas (line 4)
Figure.FaceColor = 'flat';
This is what i got
Variables = [4 10 15] % Want to paint bars 4, 10 and 15
Figure = openfig('R2-Normalized.fig');
hold on
Figure.FaceColor = 'flat';
hold on
% Paint the bars i Want
for j = 1:size(Variables,2)
aux = Variables(j);
Figure.CData(aux,:) = [1 0 0];
end
Thanks for you time!

답변 (1개)

dpb
dpb 2019년 6월 4일
Your variable Figure is the handle of the figure, not the handle of the bar object you're trying to manipulate. You'll have to go "handle diving" and retrieve those handles. See findobj documentation.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by