PlotlyJS: stacked barmode not working as expected

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:

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:

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

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.

I think that your first picture is the example above the example you expected; the one for bar2() in Bar · PlotlyJS

2 Likes

Exactly as @jd-foster said.
Use

barmode: 'group'
2 Likes

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.