# Plotly Bar Chart values not matching data

**URL:** <https://community.plotly.com/t/plotly-bar-chart-values-not-matching-data/14583>\
**Category:** 📊 Plotly Python\
**Created:** [October 16, 2018, 5:13am UTC](https://community.plotly.com/t/plotly-bar-chart-values-not-matching-data/14583 "2018-10-16T05:13:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SitaraAbraham](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sitaraabraham/32/4449_2.png) [@SitaraAbraham](https://community.plotly.com/u/SitaraAbraham)\
**Post date:** [October 16, 2018, 5:13am UTC](https://community.plotly.com/t/plotly-bar-chart-values-not-matching-data/14583/1 "2018-10-16T05:13:53Z")

</div>

Hello!

I’m pulling data from a csv file using pandas, and just to see the data, did a groupby:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/5/568f2e8e332bf8acbd202f707af83ee36716c3e5.png)

However, when I plot the data using the following code, the values in the chart don’t match the data in groupby.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/5/568f2e8e332bf8acbd202f707af83ee36716c3e5.png)

Here is the bar chart:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/7/735d2ce90329b906bacd4d45bee211cf41e5b92e.png)

I have ZERO clue where it’s getting those numbers from, let alone what the other numbers per bar are.

I’ve searched across the website but couldn’t find an example that helped or another topic. Please help!

---

<div class="post-metadata">

**Author:** ![SitaraAbraham](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sitaraabraham/32/4449_2.png) [@SitaraAbraham](https://community.plotly.com/u/SitaraAbraham)\
**Post date:** [October 16, 2018, 5:15am UTC](https://community.plotly.com/t/plotly-bar-chart-values-not-matching-data/14583/2 "2018-10-16T05:15:05Z")

</div>

My code didn’t show! Sorry about that:

import plotly.plotly as py  
import plotly.graph\_objs as go

x = content[‘Vertical’]  
y = content[‘PageViews’]

data = [go.Bar(  
x=x,  
y=y,  
text=y,  
textposition = ‘auto’,  
marker=dict(  
color=‘rgb(158,202,225)’,  
line=dict(  
color=‘rgb(8,48,107)’,  
width=1.5),  
),  
opacity=0.6  
)]

py.iplot(data, filename=‘bar-direct-labels’)

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [October 16, 2018, 10:20am UTC](https://community.plotly.com/t/plotly-bar-chart-values-not-matching-data/14583/3 "2018-10-16T10:20:41Z")

</div>

Hi @SitaraAbraham,

I’m not quite sure what result you’re looking for, but the reason that what you’re seeing looks intuitive is that the default bar mode is `'group'`, which is causing the bars to be overlayed on top of one another. But you want the bars to stack on top of each other to match the `sum` calculation.

Try adding the following layout

```python
layout={'barmode': 'stack'}
fig = dict(data=data, layout=layout)

```

Hope that helps!  
-Jon
