How can i write total number of each class to each bar?

Hi,

Im making a dashboard and in 1 part i wanna make little change.

My bar plot format and graph same with this:

import plotly.express as px
df = px.data.tips()
fig = px.bar(df, x="sex", y="total_bill", color='time')
fig.show()

but as you see, every bar contains from summation of sum value. How can I see sum of total_bill s top of each bar?

Thanks in advance!!

1 Like

I did it like this.

1 Like

Hi @bilallozdemir,

You have to use barmode='group'

import plotly.express as px
df = px.data.tips()
fig = px.bar(df, x="sex", y="total_bill", color='time', barmode='group')
fig.show()

in general Plotly has a very good documentation with plenty of examples, where you often find answers you need. Maybe have a look there next time before you post here :wink:

Best, Alex -