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

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!

1 Comment

Realize this can be done more easily using optional inputs to the bar function.
x=1:2;
y=[10 12];
new_y=[3,5];
bar(x,[y',new_y'],'stack')

Sign in to comment.

 Accepted 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

More Answers (1)

Reeve
Reeve on 5 Jun 2013
Thank you very much! This is just what I was looking for.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!