anyway to give separate color to 'stack' bar plot

2 visualizzazioni (ultimi 30 giorni)
Yu Li
Yu Li il 16 Ott 2019
Commentato: Yu Li il 16 Ott 2019
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?
untitled.jpg
Thanks!
Yu

Risposte (1)

darova
darova il 16 Ott 2019
Modificato: darova il 16 Ott 2019
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 Commenti
darova
darova il 16 Ott 2019
I have v2013. Which face will change if you try this
hBar(1).FaceColor = [1 0 0];
Yu Li
Yu Li il 16 Ott 2019
Hi:
yes, 'faceColor' works but it is only single color. I need to change all the colors.
Thanks!
Yu

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by