Stacked bar chart with both positive and negative values

Hey everyone,

I was looking for how to create a specific plot with stacked bars that have both positive and negative values. That is the plot that I am trying to recreate:

Does anybody have a suggestion on how to go about it?

Thank you very much!

I’m not sure I think that’s an intuitive way to represent mixed positive and negative numbers. Otherwise I might have suggested to edit the recipe for stacked bars.

Such graphs are used in economics usually when the positive and negative sides are intrinsically related - for example in trade balances, which is also seen in this picture. That is, if some country has a surplus, another needs to have a deficit. The graph tries to answer which countries contribute to the surplus side and which other countries contribute to the deficit side and how that changes over time.

Please have a look at this post that uses PlotlyJS

1 Like