Plot stacked bar, adjusting the colors of the bars, text in bars stacked, legend.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Marcus Vinicius Pereira de Souza
am 6 Nov. 2014
Kommentiert: Marcus Vinicius Pereira de Souza
am 6 Nov. 2014
Dear all, I need to draw a chart which I present two types of situations: theoretical lessons and practical lessons. The classes 1BMECANG and 3BMECANG only has theoretical disciplines. Already the 2BMECANG presents theoretical and practical disciplines. In this regard, I would like to: 1) the name of each subject is presented in the chart.For example: intro-36, sms-36, and so on; 2) adjust colors for theorical and practices lessons; 3) Inform through a caption that the first bar refers to the theoretical disciplines and the second to practical disciplines.
Follow the program:
%%1BMECANG
intro=36;
sms=36;
des1=72;
met1=36;
ped= 36;
%%2BMECANG
des2=72;
met2=72;
fpm1= 36;
%%3BMECANG
cm1=36;
des3=72;
mi1=36;
fpm2=36;
sfm=36;
myCT= [0 0 1
1 0 0
1 0.4 0
0 0.8 1
0.6 0 1
0 1 0]; % color of theory
myCP=[0 0.75 0.5; 0.94 0.94 0.94; 0 0 1; 1 1 0];% color of practice
P1=bar(1:2,[intro sms des1 met1 ped;nan(1,5)], 'Stacked');
colormap(myCT)
hold on
P2=bar(3:4, [des2 fpm1;nan(1,1) met2], 'Stacked');
%colormap(myCT,myCP)
hold on
P3=bar(6:7, [cm1 des3 mi1 fpm2 sfm;nan(1,5)], 'Stacked');
%colormap(myCT,myCP)
xlabels={'1BMECANG','2BMECANG','3BMECANG'};
stp=36;
Yt=0:stp:216;
set(gca, 'ytick', Yt)
set(gca, 'XTick', [1,3.5,6.0],'XtickLabel', xlabels,'FontWeight','bold','fontsize',10)
grid on
legend('Theory','Practice')
Can someone help me? Thank you very much. Best regards
2 Kommentare
Star Strider
am 6 Nov. 2014
Your code runs and seems to give the correct results.
What is not working?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance 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!