# Possible bug in stacked bar chart

**URL:** <https://community.plotly.com/t/possible-bug-in-stacked-bar-chart/40712>\
**Category:** 📊 Plotly Python\
**Created:** [June 7, 2020, 5:52am UTC](https://community.plotly.com/t/possible-bug-in-stacked-bar-chart/40712 "2020-06-07T05:52:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emilopez](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emilopez/32/8373_2.png) [@emilopez](https://community.plotly.com/u/emilopez)\
**Post date:** [June 7, 2020, 5:52am UTC](https://community.plotly.com/t/possible-bug-in-stacked-bar-chart/40712/1 "2020-06-07T05:52:52Z")

</div>

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](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

```python
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()

```

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [June 7, 2020, 4:16pm UTC](https://community.plotly.com/t/possible-bug-in-stacked-bar-chart/40712/2 "2020-06-07T16:16:15Z")

</div>

Hi @emilopez

There is NO bug! When

```auto
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:

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

```

---

<div class="post-metadata">

**Author:** ![emilopez](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emilopez/32/8373_2.png) [@emilopez](https://community.plotly.com/u/emilopez)\
**Post date:** [June 7, 2020, 9:54pm UTC](https://community.plotly.com/t/possible-bug-in-stacked-bar-chart/40712/3 "2020-06-07T21:54:31Z")

</div>

Hi @empet

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