Bar Graph with varying widths
32 views (last 30 days)
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
Without varying widths by using
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 on 19 Aug 2014
Edited: Ben11 on 19 Aug 2014
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:
I'm looking into your first question!