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

Everyone's Tags:

bar, ui

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
bar Yoav Rubin 31 Dec, 2007 06:20:27
ui Yoav Rubin 31 Dec, 2007 06:20:27
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com