course content

Course Content

Visualization in Python with matplotlib

Stacked BarsStacked Bars

Stacked bar charts are popular in cases when we want to expand our vision to multiple categories. For example, in the previous task, we may compare two Indian cities by placing the second bar right above the first one. In this case, the bar height will be the sum of two bars values.

To build a stacked bar chart we need to call the .bar() function as many times as many categories we consider. Each next .bar() function should have a bottom parameter with the y-axis values of the lower bar assigned. For example, let's represent countries' GDP by sector composition.

Everything was clear?

Section 2. Chapter 3