Skip to content

adding a diverging bar example to the horizontal bar documentation #4994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 17, 2025
Merged
Prev Previous commit
Next Next commit
separated update_xaxes from update_layout
  • Loading branch information
rl-utility-man authored Mar 16, 2025
commit be0a29e6bee6bee7b31275844e1f587f8a1e4823
13 changes: 8 additions & 5 deletions doc/python/horizontal-bar-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,15 @@ for col in ["Disagree","Strongly Disagree","Agree","Strongly Agree"]:
marker=dict(color=color_by_category[col]),
legendrank=legend_rank_by_category[col]
))

fig.update_layout(
title="Reactions to statements from the 2002 General Social Survey:",
xaxis=dict(
yaxis_title = "",
barmode='relative', # Allows bars to diverge from the center
plot_bgcolor="white",
)

fig.update_xaxes(
title="Percent of Responses",
zeroline=True, # Ensure there's a zero line for divergence
zerolinecolor="black",
Expand All @@ -277,11 +283,8 @@ fig.update_layout(
tickmode = 'array',
tickvals = [-50, 0, 50, 100],
ticktext = [50, 0, 50, 100]
),
yaxis_title = "",
barmode='relative', # Allows bars to diverge from the center
plot_bgcolor="white",
)

fig.show()
```

Expand Down