# PlotlyJS: stacked barmode not working as expected

**URL:** <https://discourse.julialang.org/t/plotlyjs-stacked-barmode-not-working-as-expected/72035>\
**Category:** General Usage\
**Tags:** plotting, plotlyjs\
**Created:** [November 24, 2021, 10:46pm UTC](https://discourse.julialang.org/t/plotlyjs-stacked-barmode-not-working-as-expected/72035 "2021-11-24T22:46:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [November 24, 2021, 10:46pm UTC](https://discourse.julialang.org/t/plotlyjs-stacked-barmode-not-working-as-expected/72035/1 "2021-11-24T22:46:45Z")

</div>

Hi,

I was having a problem with a plot using the stacked bar mode and thought that I would be doing something wrong. I did not understand why because it used to work in the past. So I tried the example in the PlotlyJS documentation:

```julia
using PlotlyJS
function bar3()
    trace1 = bar(;x=["giraffes", "orangutans", "monkeys"],
                  y=[20, 14, 23],
                  name="SF Zoo")
    trace2 = bar(x=["giraffes", "orangutans", "monkeys"],
                 y=[12, 18, 29],
                 name="LA Zoo")
    data = [trace1, trace2]
    layout = Layout(;barmode="stack")
    plot(data, layout)
end
bar3()

```

I was supposed to get this plot:

 ![a](https://global.discourse-cdn.com/julialang/original/3X/e/9/e9762c20ada0f1780d5e700a656723c823f8e66d.png)

However, what I get is this (in VScode, Atom and Pluto):

 ![aa](https://global.discourse-cdn.com/julialang/original/3X/8/1/814e71e54e3a2b9cc15d70ae181ad08e0996e856.png)

Don’t know what is happening. I am on a Windows 10 machine, using Julia 1.6.4, PlotlyJS v0.18.8, PlotlyBase v0.8.18.

Help will be very much appreciated. Thanks.

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [November 25, 2021, 12:05am UTC](https://discourse.julialang.org/t/plotlyjs-stacked-barmode-not-working-as-expected/72035/2 "2021-11-25T00:05:32Z")

</div>

I think that your first picture is the example above the example you expected; the one for `bar2()` in [Bar · PlotlyJS](http://juliaplots.org/PlotlyJS.jl/stable/examples/bar/)

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [November 25, 2021, 7:05am UTC](https://discourse.julialang.org/t/plotlyjs-stacked-barmode-not-working-as-expected/72035/3 "2021-11-25T07:05:26Z")

</div>

Exactly as @jd-foster said.  
Use

```julia
barmode: 'group'

```

---

<div class="post-metadata">

**Author:** ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)\
**Post date:** [November 25, 2021, 10:41am UTC](https://discourse.julialang.org/t/plotlyjs-stacked-barmode-not-working-as-expected/72035/4 "2021-11-25T10:41:16Z")

</div>

Hahaha, this is the effect of getting too much into Pluto’s mindset. Who said that output below/above code cell is irrelevant? @jd-foster, @oheil, thank you very much for taking the time to reply to a stupid question.
