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:
bar plot using colormap

Subject: bar plot using colormap

From: J G

Date: 24 May, 2012 03:13:13

Message: 1 of 2

Very simple problem - not sure what I'm doing wrong...
I want to make each bar a different color using the colormap bone. Here is my code so far:

X = [0.19 0.18 0.12 0.04 0.19 0.12 0.12];
b = bar(X);
p = bone(7);
ch = get(b,'children');
set(ch(1),'Facecolor', p(1,:))
set(ch(2),'Facecolor', p(2,:))

Subject: bar plot using colormap

From: J G

Date: 24 May, 2012 04:11:10

Message: 2 of 2

figure it out

bh = bar(X);
ch=get(bh,'children');
cd=repmat(1:numel(X),5,1);
cd=[cd(:);nan];
set(ch,'facevertexcdata',cd);
colormap(bone);

Tags for this Thread

No tags are associated with 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