Plotly Bar Chart values not matching data

Hello!

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

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

Here is the bar chart:

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!

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’)

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

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

Hope that helps!
-Jon