File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Expand file tree Collapse file tree 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"]:
236236fig = go.Figure(layout = go.Layout(
237237 title = " Reactions to statements from the 2002 General Social Survey:" ,
238238 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+ )
241254
242255
243256# 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(
305318 )
306319)
307320
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-
319321fig.show()
320322```
321323
You can’t perform that action at this time.
0 commit comments