@@ -91,8 +91,8 @@ fig.add_trace(go.Bar(
91
91
name = ' SF Zoo' ,
92
92
orientation = ' h' ,
93
93
marker = dict (
94
- color = ' rgba(246, 78, 139, 0.6) ' ,
95
- line = dict (color = ' rgba(246, 78, 139, 1.0) ' , width = 3 )
94
+ color = ' hotpink ' ,
95
+ line = dict (color = ' deeppink ' , width = 3 )
96
96
)
97
97
))
98
98
fig.add_trace(go.Bar(
@@ -101,8 +101,8 @@ fig.add_trace(go.Bar(
101
101
name = ' LA Zoo' ,
102
102
orientation = ' h' ,
103
103
marker = dict (
104
- color = ' rgba(58, 71, 80, 0.6) ' ,
105
- line = dict (color = ' rgba(58, 71, 80, 1.0) ' , width = 3 )
104
+ color = ' dimgray ' ,
105
+ line = dict (color = ' black ' , width = 3 )
106
106
)
107
107
))
108
108
@@ -118,10 +118,8 @@ import plotly.graph_objects as go
118
118
top_labels = [' Strongly<br>agree' , ' Agree' , ' Neutral' , ' Disagree' ,
119
119
' Strongly<br>disagree' ]
120
120
121
- colors = [' rgba(38, 24, 74, 0.8)' , ' rgba(71, 58, 131, 0.8)' ,
122
- ' rgba(122, 120, 168, 0.8)' , ' rgba(164, 163, 204, 0.85)' ,
123
- ' rgba(190, 192, 213, 1)' ]
124
-
121
+ colors = [' DarkBlue' , ' MediumBlue' , ' cyan' , ' mediumpurple' , ' thistle' ]
122
+ # , 'silver'
125
123
x_data = [[21 , 30 , 21 , 16 , 12 ],
126
124
[24 , 31 , 19 , 15 , 11 ],
127
125
[27 , 26 , 23 , 11 , 13 ],
@@ -142,7 +140,7 @@ for i in range(0, len(x_data[0])):
142
140
orientation = ' h' ,
143
141
marker = dict (
144
142
color = colors[i],
145
- line = dict (color = ' rgb(248, 248, 249) ' , width = 1 )
143
+ line = dict (color = ' ghostwhite ' , width = 1 )
146
144
)
147
145
))
148
146
@@ -161,8 +159,8 @@ fig.update_layout(
161
159
zeroline = False ,
162
160
),
163
161
barmode = ' stack' ,
164
- paper_bgcolor = ' rgb(248, 248, 255) ' ,
165
- plot_bgcolor = ' rgb(248, 248, 255) ' ,
162
+ paper_bgcolor = ' lavenderblush ' ,
163
+ plot_bgcolor = ' lavenderblush ' ,
166
164
margin = dict (l = 120 , r = 10 , t = 140 , b = 80 ),
167
165
showlegend = False ,
168
166
)
@@ -176,22 +174,22 @@ for yd, xd in zip(y_data, x_data):
176
174
xanchor = ' right' ,
177
175
text = str (yd),
178
176
font = dict (family = ' Arial' , size = 14 ,
179
- color = ' rgb(67, 67, 67) ' ),
177
+ color = ' dimgray ' ),
180
178
showarrow = False , align = ' right' ))
181
179
# labeling the first percentage of each bar (x_axis)
182
180
annotations.append(dict (xref = ' x' , yref = ' y' ,
183
181
x = xd[0 ] / 2 , y = yd,
184
182
text = str (xd[0 ]) + ' %' ,
185
183
font = dict (family = ' Arial' , size = 14 ,
186
- color = ' rgb(248, 248, 255) ' ),
184
+ color = ' white ' ),
187
185
showarrow = False ))
188
186
# labeling the first Likert scale (on the top)
189
187
if yd == y_data[- 1 ]:
190
188
annotations.append(dict (xref = ' x' , yref = ' paper' ,
191
189
x = xd[0 ] / 2 , y = 1.1 ,
192
190
text = top_labels[0 ],
193
191
font = dict (family = ' Arial' , size = 14 ,
194
- color = ' rgb(67, 67, 67) ' ),
192
+ color = ' dimgray ' ),
195
193
showarrow = False ))
196
194
space = xd[0 ]
197
195
for i in range (1 , len (xd)):
@@ -200,15 +198,15 @@ for yd, xd in zip(y_data, x_data):
200
198
x = space + (xd[i]/ 2 ), y = yd,
201
199
text = str (xd[i]) + ' %' ,
202
200
font = dict (family = ' Arial' , size = 14 ,
203
- color = ' rgb(248, 248, 255) ' ),
201
+ color = f " { ' white ' * (i < 2 ) }{ ' black ' * (i >= 2 ) } " ),
204
202
showarrow = False ))
205
203
# labeling the Likert scale
206
204
if yd == y_data[- 1 ]:
207
205
annotations.append(dict (xref = ' x' , yref = ' paper' ,
208
206
x = space + (xd[i]/ 2 ), y = 1.1 ,
209
207
text = top_labels[i],
210
208
font = dict (family = ' Arial' , size = 14 ,
211
- color = ' rgb(67, 67, 67) ' ),
209
+ color = ' dimgray ' ),
212
210
showarrow = False ))
213
211
space += xd[i]
214
212
@@ -314,9 +312,9 @@ fig.add_trace(go.Bar(
314
312
x = y_saving,
315
313
y = x,
316
314
marker = dict (
317
- color = ' rgba(50, 171, 96, 0.6) ' ,
315
+ color = ' mediumseagreen ' ,
318
316
line = dict (
319
- color = ' rgba(50, 171, 96, 1.0) ' ,
317
+ color = ' seagreen ' ,
320
318
width = 1 ),
321
319
),
322
320
name = ' Household savings, percentage of household disposable income' ,
@@ -326,7 +324,7 @@ fig.add_trace(go.Bar(
326
324
fig.add_trace(go.Scatter(
327
325
x = y_net_worth, y = x,
328
326
mode = ' lines+markers' ,
329
- line_color = ' rgb(128, 0, 128) ' ,
327
+ line_color = ' purple ' ,
330
328
name = ' Household net worth, Million USD/capita' ,
331
329
), 1 , 2 )
332
330
@@ -342,7 +340,7 @@ fig.update_layout(
342
340
showgrid = False ,
343
341
showline = True ,
344
342
showticklabels = False ,
345
- linecolor = ' rgba(102, 102, 102, 0.8) ' ,
343
+ linecolor = ' gray ' ,
346
344
linewidth = 2 ,
347
345
domain = [0 , 0.85 ],
348
346
),
@@ -364,8 +362,8 @@ fig.update_layout(
364
362
),
365
363
legend = dict (x = 0.029 , y = 1.038 , font_size = 10 ),
366
364
margin = dict (l = 100 , r = 20 , t = 70 , b = 70 ),
367
- paper_bgcolor = ' rgb(248, 248, 255) ' ,
368
- plot_bgcolor = ' rgb(248, 248, 255) ' ,
365
+ paper_bgcolor = ' lavenderblush ' ,
366
+ plot_bgcolor = ' lavenderblush ' ,
369
367
)
370
368
371
369
annotations = []
@@ -380,14 +378,14 @@ for ydn, yd, xd in zip(y_nw, y_s, x):
380
378
y = xd, x = ydn - 20000 ,
381
379
text = ' {:, } ' .format(ydn) + ' M' ,
382
380
font = dict (family = ' Arial' , size = 12 ,
383
- color = ' rgb(128, 0, 128) ' ),
381
+ color = ' purple ' ),
384
382
showarrow = False ))
385
383
# labeling the bar net worth
386
384
annotations.append(dict (xref = ' x1' , yref = ' y1' ,
387
385
y = xd, x = yd + 3 ,
388
386
text = str (yd) + ' %' ,
389
- font = dict (family = ' Arial' , size = 12 ,
390
- color = ' rgb(50, 171, 96) ' ),
387
+ font = dict (family = ' Arial' , size = 16 ,
388
+ color = ' mediumseagreen ' ),
391
389
showarrow = False ))
392
390
# Source
393
391
annotations.append(dict (xref = ' paper' , yref = ' paper' ,
@@ -396,7 +394,7 @@ annotations.append(dict(xref='paper', yref='paper',
396
394
' (2015), Household savings (indicator), ' +
397
395
' Household net worth (indicator). doi: ' +
398
396
' 10.1787/cfc6f499-en (Accessed on 05 June 2015)' ,
399
- font = dict (family = ' Arial' , size = 10 , color = ' rgb(150,150,150) ' ),
397
+ font = dict (family = ' Arial' , size = 10 , color = ' gray ' ),
400
398
showarrow = False ))
401
399
402
400
fig.update_layout(annotations = annotations)
0 commit comments