anyway to give separate color to 'stack' bar plot
Show older comments
Hi:
I read an post from link below:
which provide a way to add annotation to the individual of each data. I would like to know if there is anyway to control the color of each individual bar?

Thanks!
Yu
Answers (1)
Do you have colors you want to paint bars into?
for i = 1:length(hBar)
h1 = get(hBar(i),'Children');
n = length( get(h1,'FaceVertexCdata') );
set(h1,'faceVertexCdata',rand(n,3))
end
5 Comments
Yu Li
on 16 Oct 2019
darova
on 16 Oct 2019
I think a have older version of MATLAB
for i = 1:length(hBar)
n = length( get(hBar(i),'FaceVertexCdata') );
set(hBar(i),'faceVertexCdata',rand(n,3))
end
darova
on 16 Oct 2019
I have v2013. Which face will change if you try this
hBar(1).FaceColor = [1 0 0];
Yu Li
on 16 Oct 2019
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!