Skip to content

Commit be52c35

Browse files
replace an update_layout call with a go.figure() call
1 parent d5e2284 commit be52c35

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/python/horizontal-bar-charts.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,13 @@ df.rename(columns={'Unnamed: 0':"Category"}, inplace=True)
233233
for v in ["Disagree","Strongly Disagree"]:
234234
df[v]=df[v]*-1
235235

236-
fig = go.Figure()
236+
fig = go.Figure(layout=go.Layout(
237+
title="Reactions to statements from the 2002 General Social Survey:",
238+
plot_bgcolor="white",
239+
barmode='relative' # Allows bars to diverge from the center
240+
))
241+
242+
237243
# this color palette conveys meaning: blues for agreement, reds and oranges for disagreement, gray for Neither Agree nor Disagree
238244
color_by_category={
239245
"Strongly Agree":'darkblue',
@@ -283,12 +289,6 @@ max_right = max(df[["Agree","Strongly Agree"]].sum(axis=1))
283289
max_width_signed = abs(max_left)+max_right
284290
max_width_neither = max(df["Neither Agree nor Disagree"])
285291

286-
fig.update_layout(
287-
title="Reactions to statements from the 2002 General Social Survey:",
288-
plot_bgcolor="white",
289-
barmode='relative', # Allows bars to diverge from the center
290-
)
291-
292292
fig.update_xaxes(
293293
zeroline=True, #the zero line distinguishes between positive and negative segments
294294
zerolinecolor="black",

0 commit comments

Comments
 (0)