File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -236,8 +236,21 @@ for v in ["Disagree","Strongly Disagree"]:
236
236
fig = go.Figure(layout = go.Layout(
237
237
title = " Reactions to statements from the 2002 General Social Survey:" ,
238
238
plot_bgcolor = " white" ,
239
- barmode = ' relative' # Allows bars to diverge from the center
240
- ))
239
+ barmode = ' relative' , # Allows bars to diverge from the center
240
+ # Put the legend at the bottom center of the figure
241
+ legend = dict (
242
+ orientation = " h" , # a horizontal legend matches the horizontal bars
243
+ yref = " container" ,
244
+ yanchor = " bottom" ,
245
+ y = 0.02 ,
246
+ xanchor = " center" ,
247
+ x = 0.5 ),
248
+ # use an unlabeled Y axis, since we're going to list specific questions on the y-axis.
249
+ yaxis = dict (
250
+ title = " "
251
+ ),
252
+ )
253
+ )
241
254
242
255
243
256
# this color palette conveys meaning: blues for agreement, reds and oranges for disagreement, gray for Neither Agree nor Disagree
@@ -305,17 +318,6 @@ fig.update_layout(
305
318
)
306
319
)
307
320
308
- fig.update_legends(
309
- orientation = " h" , # a horizontal legend matches the horizontal bars
310
- yref = " container" ,
311
- yanchor = " bottom" ,
312
- y = 0.02 ,
313
- xanchor = " center" ,
314
- x = 0.5
315
- )
316
-
317
- fig.update_yaxes(title = " " )
318
-
319
321
fig.show()
320
322
```
321
323
You can’t perform that action at this time.
0 commit comments