Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replace an update_layout call with a go.figure() call
  • Loading branch information
rl-utility-man authored Apr 16, 2025
commit be52c356874246da013f5d9d4469cfb0e780154a
14 changes: 7 additions & 7 deletions doc/python/horizontal-bar-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@ df.rename(columns={'Unnamed: 0':"Category"}, inplace=True)
for v in ["Disagree","Strongly Disagree"]:
df[v]=df[v]*-1

fig = go.Figure()
fig = go.Figure(layout=go.Layout(
title="Reactions to statements from the 2002 General Social Survey:",
plot_bgcolor="white",
barmode='relative' # Allows bars to diverge from the center
))


# this color palette conveys meaning: blues for agreement, reds and oranges for disagreement, gray for Neither Agree nor Disagree
color_by_category={
"Strongly Agree":'darkblue',
Expand Down Expand Up @@ -283,12 +289,6 @@ max_right = max(df[["Agree","Strongly Agree"]].sum(axis=1))
max_width_signed = abs(max_left)+max_right
max_width_neither = max(df["Neither Agree nor Disagree"])

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

fig.update_xaxes(
zeroline=True, #the zero line distinguishes between positive and negative segments
zerolinecolor="black",
Expand Down