Skip to content
Advertisement

How to annotate each segment of a stacked bar chart

enter image description here

I’ve been trying to annotate each sub-amount of a stacked bar chart with its values like the picture shown above (values not accurate, just an example).

JavaScript

Data frame that I used: enter image description here

The linked post is somewhat similar to my question but I do not understand the code given in that answer nor were there any explanations given.

Annotating Values in Stacked Bar Chart Matplotlib

Advertisement

Answer

Imports and DataFrame

JavaScript

Update as of matplotlib v3.4.2

JavaScript

enter image description here

Original Answer – prior to matplotlib v3.4.2

JavaScript

enter image description here

Advertisement