MATLAB: How to plot a bar on a bar in a bar graph

barhist

Hi,
I would like to plot a bar graph, and then have a percentage of each bar "shaded out" or change color to indicated what percentage of this data passed a check.
The link below is a picture depicting what I would like to plot:
Thanks!

Best Answer

x=1:2;
y=[10 12];
perc=[25 50];
new_y=[y.*perc/100];
bar(x,y,'b'),
hold on,
bar(x,new_y,'b')
alpha(0.2)
hold off