Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created June 12, 2020 12:47
Show Gist options
  • Save BetterProgramming/be53adb6beb33a8aaa634a1f8cee7f1e to your computer and use it in GitHub Desktop.
Save BetterProgramming/be53adb6beb33a8aaa634a1f8cee7f1e to your computer and use it in GitHub Desktop.
sal = df.loc[:,["salary", "gender"]].groupby(["salary", "gender"]).size().reset_index()
sal.columns = ["Salary", "Gender", "Count"]
fig = px.bar(sal, x='Salary', y='Count', color="Gender",
barmode='group', title ="Salary Gender Distribution",
height=400, width=2000)
fig.update_traces(marker_line_color='rgb(9,50,100)',
marker_line_width=1.5, opacity=0.6)
fig.show()
@KyeraFrancis
Copy link

Suggestion: For this visualization, adding a legend would help understand the colors, because you split the visualization.

fig.update_layout(showlegend=True, legend_title_text='Gender')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment