How to change color of box with bar function?

Hi all, I am using bar function for my table chart. I want to change 'Attacked' box from blue color to red color. I used findobj function to find 'Attacked' box and set color but it's not working. Anyone have any idea? Thank in advance! Here is my code:
str={'Normal';'Attacked'};
x=[1;2];
y=[142 ;4128 ];
b=bar(x,y,0.3);
set(gca,'xticklabel',str)

 Akzeptierte Antwort

B.k Sumedha
B.k Sumedha am 25 Jun. 2015

0 Stimmen

U can use this.
b=bar(x,diag(y),'stacked');

2 Kommentare

Tung
Tung am 25 Jun. 2015
it worked. Thank so much!
B.k Sumedha
B.k Sumedha am 25 Jun. 2015
Your welcome :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 25 Jun. 2015

Kommentiert:

am 25 Jun. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by