MATLAB Answers

Tung
0

How to change color of box with bar function?

Asked by Tung
on 25 Jun 2015
Latest activity Commented on by B.k Sumedha on 25 Jun 2015
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)

  0 Comments

Sign in to comment.

1 Answer

Answer by B.k Sumedha on 25 Jun 2015
 Accepted Answer

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

  2 Comments

it worked. Thank so much!
Your welcome :)

Sign in to comment.