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 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 (2020). MATLAB Plot Gallery - Stacked Bar Chart (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (3)

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



Added live script

Updated license

Updated screenshot.

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

Inspired: superbar