Bar Graph with varying widths

6 ビュー (過去 30 日間)
Arif Can Gungor
Arif Can Gungor 2014 年 8 月 19 日
編集済み: Arif Can Gungor 2014 年 8 月 19 日
Hi all,
I was trying to get a stacked bar graph with varying widths. Is it possible? Could someone help me?
Here are the variables I am trying to plot.
These are the value to be plotted in a stacked bar graph
graf =
0.2075 2.1825
0.4312 1.9600
0.0370 2.3600
0.3107 2.0800
0.1172 2.2800
1.3685 1.0200
0.8685 1.5200
0.1610 2.2300
1.0000 0.9300
0.3107 0.6900
Without varying widths by using
bar(graf,'stack');
I can get a nice graph like this:
But I also need bars with varying widths, for example, here are my desired widths:
2 1 3 1 4 3 2 2 1 3
Is there any way I can obtain such a plot? And also a minor question, do you know how I can change colors in a stacked bar graph?
Thanks a lot,

採用された回答

Ben11
Ben11 2014 年 8 月 19 日
編集済み: Ben11 2014 年 8 月 19 日
For your 2nd question:
In order to change the bar colors, use findobj to get the patch objects forming the bars and change their color:
hBars = findobj(gca,'type','patch')
will give a 2-element array of handles, where each color is change individually like so:
set(hBars(1),'FaceColor','g')
set(hBars(2),'FaceColor','c')
I'm looking into your first question!
  1 件のコメント
Arif Can Gungor
Arif Can Gungor 2014 年 8 月 19 日
編集済み: Arif Can Gungor 2014 年 8 月 19 日
Thanks a lot, For my first question I have found this http://www.mathworks.com/matlabcentral/newsreader/view_thread/77839
However, I can't adapt this to stacked version.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by