File Exchange

image thumbnail

MATLAB Plot Gallery - Stacked Bar Chart

version (26.1 KB) by MathWorks Plot Gallery Team
Create a stacked bar chart


Updated 19 Dec 2018

View Version History

View License

This is an example of how to create a stacked bar chart in MATLAB®.
Read about the "bar" function in the MATLAB documentation.
For more examples, go to MATLAB Plot Gallery -

Cite As

MathWorks Plot Gallery Team (2021). MATLAB Plot Gallery - Stacked Bar Chart (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (4)


Timur Kelin

1. The order of of the colours on the bars and on the legend is opposed. This doesn't look nice.
2. Irrespective to this example: 'stack' doesn't work for a stacked single bar. Fake data for the second bar should be added to the input data.

Serena Todd


MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: superbar

Community Treasure Hunt

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

Start Hunting!