Combine three different set bar graphs in one graph

3 ビュー (過去 30 日間)
Prateek Gupta
Prateek Gupta 2018 年 3 月 26 日
コメント済み: M 2018 年 3 月 28 日
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')

回答 (1 件)

M
M 2018 年 3 月 27 日
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 件のコメント
Prateek Gupta
Prateek Gupta 2018 年 3 月 27 日
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 2018 年 3 月 28 日

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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by