# Stacked bar chart with both positive and negative values

**URL:** <https://discourse.julialang.org/t/stacked-bar-chart-with-both-positive-and-negative-values/70852>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [November 3, 2021, 8:39am UTC](https://discourse.julialang.org/t/stacked-bar-chart-with-both-positive-and-negative-values/70852 "2021-11-03T08:39:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [November 3, 2021, 8:39am UTC](https://discourse.julialang.org/t/stacked-bar-chart-with-both-positive-and-negative-values/70852/1 "2021-11-03T08:39:52Z")

</div>

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:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/8/68bb01c365e668a895a823ba166d4f191d7ca42a.png)

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

Thank you very much!

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [November 3, 2021, 9:44am UTC](https://discourse.julialang.org/t/stacked-bar-chart-with-both-positive-and-negative-values/70852/2 "2021-11-03T09:44:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [November 3, 2021, 9:48am UTC](https://discourse.julialang.org/t/stacked-bar-chart-with-both-positive-and-negative-values/70852/3 "2021-11-03T09:48:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 3, 2021, 10:16am UTC](https://discourse.julialang.org/t/stacked-bar-chart-with-both-positive-and-negative-values/70852/4 "2021-11-03T10:16:09Z")

</div>

Please have a look at [this post](https://discourse.julialang.org/t/plotly-js-stacked-bars-in-subplots/60856/3) that uses `PlotlyJS`
