My aim is to make same thing in plotly: sns.countplot(x='Survived', data=train, hue='Sex') enter image description here
Then I wrote this code. But I couldn't print y values:
df1 = df[df["Survived"] == 0]
df2 = df[df["Survived"] == 1]
fig = go.Figure()
# Create layout and specify title, legend and so on
fig.add_trace(go.Bar(
x=df["Sex"],
y=df2,
name="Survived",
marker_color='lightgreen'
))
fig.add_trace(go.Bar(
x=df["Sex"],
y=df1,
name= "Died",
marker_color="red"
))
fig.update_layout(title_text='Survived/Died passengers by Sex', barmode='group')
#fig.layout.yaxis.type = 'category'
fig.show()
By the way, I used the titanic dataset.
Saw this on StackOverflow but didn't help.
Any help?