How to make zero-value bar in bar graph visible?

I'm plotting a bar graph with the test results. Some of the scores in the test are 0, which makes the bars almost invisible. How to extend the bars so that they are all clearly visible, even the ones with value 0?

 Accepted Answer

Change the color of the bar graph, use the different face color and edge color
as following
y=[75 91 105 123.5 0 150 179 203 226 249 281.5];
bar(y,'r','FaceColor',[0 .5 .5],'EdgeColor',[0 .9 .9],'LineWidth',5)
You can do some sorts of ways, change values as per your requirements-

4 Comments

Also, you can change the baseline (-1 or - some value as per your requirements) of the bar chart so that 0 is also visible. Check here how to change the baseline, check here
Thank You! Can You also advise me on other case: in my bar graph I have data in arrays which have 7 rows and in arrays with 5 rows. I want to show them all on one graph, but for the arrays with 5 rows matlab draws the other 2 rows as zero values, so it looks like this:
How to delete those 0-value bars? Thanks in advance for the answer!
Before plot you can delete the 0 from the array
y=[75 91 105 123.5 0 150 179 203 226 249 281.5];
>> y1=y(y>0)
y1 =
75.0000 91.0000 105.0000 123.5000 150.0000 179.0000 203.0000 226.0000 249.0000 281.5000
Hi, thanks for the answer. However, there are no zeros in the 3 smaller arrays. They are all 5x3 arrays with no 0-values.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!