Possible bug in stacked bar chart

Hil all, I think there is a possible bug or an anomally behaviour using stacked bar chart.

Following the example from here https://plotly.com/python/bar-charts/#stacked-bar-chart
if you change an str from the list animals and use a number string (for example β€˜2’ ) plotly will fail.
It was tested in 4.5.0 and 4.8.1 with the same results

import plotly.graph_objects as go

# here I replaced 'orangutans' with '2'
animals=['giraffes', '2', 'monkeys']

fig = go.Figure(data=[
    go.Bar(name='SF Zoo', x=animals, y=[20, 14, 23]),
    go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29])
])
# Change the bar mode
fig.update_layout(barmode='stack')
fig.show()

Hi @emilopez

There is NO bug! When

animals=['giraffes', 'orangutans', 'monkeys']

it is obvious that xaxis is of type 'category', but when you replace β€˜orangutans’ with '2', since '2'is an integer converted to string, it’s not so obvious the xaxis type and you must perform the following layout updates to get the right bar chart:

fig.update_layout(barmode='stack',
                  xaxis_type='category')

Hi @empet

It was a bit confusing for me.
Thanks for your help!