How to not repeat colors plotting with barh?
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Luca Repetto
am 20 Jul. 2021
Kommentiert: Luca Repetto
am 28 Jul. 2021
Hello,
I'm plotting a Gantt chart and I have 10 jobs, as you can see from the image after the 6th job the colours are repeating themselves, how can I tell to not repeat them?
I also have another question, how can I plot inside each bar the name of the job? So that I won't have anymore to use the legend.
Thank you in advance.
0 Kommentare
Akzeptierte Antwort
Vineet Joshi
am 28 Jul. 2021
Hi
The following code might help you in the same.
X = [1];
Y10 = [5 5 5 5 5 5 5 5 5 5];
bar_obj = barh(X,Y10,'stacked','FaceColor','flat');
bar_obj(8).CData = [0 1 0];
bar_obj(9).CData = [1 1 0.5];
bar_obj(10).CData = [1 0.5 0.5];
As you can see, all the colours are unique.
Hope this helps.
Thanks
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!