Combine three different set bar graphs in one graph

3 vues (au cours des 30 derniers jours)
Prateek Gupta
Prateek Gupta le 26 Mar 2018
Commenté : M le 28 Mar 2018
I have three sets of bar graphs. How can I just place them on one graph with some spacing between each set and with each set having a different colour? three sets are: 1) vector_22=[000,001,010,011,100,101,110,111] leak_22=[5.33,5.46,4.45,4.47,4.41,3.90,4.36,3.71]; bar(leak_22); set(gca, 'xticklabel',{'000','001','010','011','100','101','110','111'}); text(1:length(leak_22),leak_22,num2str(leak_22'),'vert','bottom','horiz','center'); xlabel('Input Vector Applied'); ylabel('Leakage in nW');
2) vector_32=[000,001,010,011,100,101,110,111] leak_32=[4.46,4.50,3.69,3.67,3.63,3.24,3.63,3.17]; bar(leak_32); set(gca, 'xticklabel',{'000','001','010','011','100','101','110','111'}); text(1:length(leak_32),leak_32,num2str(leak_32'),'vert','bottom','horiz','center'); xlabel('Input Vector Applied'); ylabel('Leakage in nW');
3) vector_45=[000,001,010,011,100,101,110,111] leak_45=[3.65,3.69,3.04,3.0,2.98,2.69,2.99,2.66]; bar(leak_45); set(gca, 'xticklabel',{'000','001','010','011','100','101','110','111'}); text(1:length(leak_45),leak_45,num2str(leak_45'),'vert','bottom','horiz','center'); xlabel('Input Vector Applied') ylabel('Leakage in nW')

Réponses (1)

M
M le 27 Mar 2018
You can group your 3 bar graphs using something like this:
b=bar([leak_22;leak_32;leak_45]);
For your example, you will have 3 groups of 8 bars.
If you want 8 groups of 3 bars, use the transpose of your vectors.
You can then change the color of specific bar using:
b(1).FaceColor='blue';
You can also change the line style and others properties.
  4 commentaires
Prateek Gupta
Prateek Gupta le 27 Mar 2018
b=bar([leak_22;leak_32;leak_45]); with this command I'm getting 8 colours bar. But I want each set of 8 bars of 1 colour only. Thanks!
M
M le 28 Mar 2018

Try

leak_32=[4.46,4.50,3.69,3.67,3.63,3.24,3.63,3.17]'; 
leak_22=[5.33,5.46,4.45,4.47,4.41,3.90,4.36,3.71]'; 
leak_45=[3.65,3.69,3.04,3.0,2.98,2.69,2.99,2.66]'; 
b=bar3([leak_22 leak_32 leak_45]); 

And see if it corresponds to your needs.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by