Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Controling colors of columns in a bar graph

Subject: Controling colors of columns in a bar graph

From: Yoav Rubin

Date: 31 Dec, 2007 11:16:15

Message: 1 of 2

Hi All,
I am using the bar command to display matrix values in a bar
graph, and I'd like to find a way to control the color that
is assigned to each column in the matrix, e.g., I have a
matrix that its size is 100x20, thus after calling
bar(myMatrix) i get a bar graph with 20 bars for each bin.
I'd like that the first bin will be red, the second blue
and so on. Is there a way to specify for each column in a
bin its color?

thanks
Yoav

Subject: Controling colors of columns in a bar graph

From: Huy

Date: 31 Dec, 2007 16:04:51

Message: 2 of 2

"Yoav Rubin" <yoavrubin@hotmail.com> wrote in message
<flaj1v$6ph$1@fred.mathworks.com>...
> Hi All,
> I am using the bar command to display matrix values in a bar
> graph, and I'd like to find a way to control the color that
> is assigned to each column in the matrix, e.g., I have a
> matrix that its size is 100x20, thus after calling
> bar(myMatrix) i get a bar graph with 20 bars for each bin.
> I'd like that the first bin will be red, the second blue
> and so on. Is there a way to specify for each column in a
> bin its color?
>
> thanks
> Yoav

h = bar(rand(5,10));

set(h(1),'FaceColor','r')

or

set(h(1),'FaceColor',[1 0 0])

Anh Huy Phan
RIKEN - BSI

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us