horizontal bar graphs/ figures
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
how do i plot specific colours with a barh graph. i can plot specific colours for the first stacked bar graph but not for the second as h =barh... only produces 'h' values for the first stacked bar graph. Any help would be appreciated. Thx
MJ_Green= 50;
MJ_Yellow= 5;
MJ_Red=25;
MN_Yellow =5;
MN_Green=25;
MN_Red=50;
Red_time_both= 2;
%
Phasing_ALL = [MJ_Green, MJ_Yellow, MJ_Red, Red_time_both ; MN_Red, MN_Green, MN_Yellow, Red_time_both];
h = barh(Phasing_ALL,0.5,'stacked');
xlabel('Seconds','FontSize',12);
set(gca,'yticklabel',{'Major Road','Minor Road'});
set(h(1),'Facecolor','g');
set(h(2),'Facecolor','y');
set(h(3),'Facecolor','r');
set(h(4),'Facecolor','m');
need to set colours for second bar also.
0 Kommentare
Akzeptierte Antwort
Wayne King
am 1 Okt. 2013
You have to realize that in a stacked bar plot you really have 2 bar plot objects, not 3 like you seem to think. You can modify the two 'Facecolors', the first group of bars and the second group
A = [50 25; 5 5 ; 25 50];
h = barh(A,0.75,'stacked');
xlabel('Seconds');
set(gca,'yticklabel',{'Green','Yellow','Red'});
set(h(1),'Facecolor','yellow');
set(h(2),'Facecolor','red');
Or pass a vector
A = [50 25; 5 5 ; 25 50];
h = barh(A,0.75,'stacked');
xlabel('Seconds');
set(gca,'yticklabel',{'Green','Yellow','Red'});
set(h(1),'Facecolor',[0.5 0.5 0.5]);
set(h(2),'Facecolor',[1 1 1]);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Bar Plots 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!