@@ -167,10 +167,10 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
167
167
fit_results = None
168
168
hover_header = ""
169
169
custom_data_len = 0
170
- for k in trace_spec .attrs :
171
- v = args [k ]
172
- v_label = get_decorated_label (args , v , k )
173
- if k == "dimensions" :
170
+ for attr_name in trace_spec .attrs :
171
+ v = args [attr_name ]
172
+ v_label = get_decorated_label (args , v , attr_name )
173
+ if attr_name == "dimensions" :
174
174
dims = [
175
175
(name , column )
176
176
for (name , column ) in trace_data .iteritems ()
@@ -198,26 +198,26 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
198
198
199
199
elif (
200
200
v is not None
201
- or (trace_spec .constructor == go .Histogram and k in ["x" , "y" ])
201
+ or (trace_spec .constructor == go .Histogram and attr_name in ["x" , "y" ])
202
202
or (
203
203
trace_spec .constructor in [go .Histogram2d , go .Histogram2dContour ]
204
- and k == "z"
204
+ and attr_name == "z"
205
205
)
206
206
):
207
- if k == "size" :
207
+ if attr_name == "size" :
208
208
if "marker" not in result :
209
209
result ["marker" ] = dict ()
210
210
result ["marker" ]["size" ] = trace_data [v ]
211
211
result ["marker" ]["sizemode" ] = "area"
212
212
result ["marker" ]["sizeref" ] = sizeref
213
213
mapping_labels [v_label ] = "%{marker.size}"
214
- elif k == "marginal_x" :
214
+ elif attr_name == "marginal_x" :
215
215
if trace_spec .constructor == go .Histogram :
216
216
mapping_labels ["count" ] = "%{y}"
217
- elif k == "marginal_y" :
217
+ elif attr_name == "marginal_y" :
218
218
if trace_spec .constructor == go .Histogram :
219
219
mapping_labels ["count" ] = "%{x}"
220
- elif k == "trendline" :
220
+ elif attr_name == "trendline" :
221
221
if (
222
222
v in ["ols" , "lowess" ]
223
223
and args ["x" ]
@@ -255,16 +255,16 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
255
255
mapping_labels [get_label (args , args ["x" ])] = "%{x}"
256
256
mapping_labels [get_label (args , args ["y" ])] = "%{y} <b>(trend)</b>"
257
257
258
- elif k .startswith ("error" ):
259
- error_xy = k [:7 ]
260
- arr = "arrayminus" if k .endswith ("minus" ) else "array"
258
+ elif attr_name .startswith ("error" ):
259
+ error_xy = attr_name [:7 ]
260
+ arr = "arrayminus" if attr_name .endswith ("minus" ) else "array"
261
261
if error_xy not in result :
262
262
result [error_xy ] = {}
263
263
result [error_xy ][arr ] = trace_data [v ]
264
- elif k == "custom_data" :
264
+ elif attr_name == "custom_data" :
265
265
result ["customdata" ] = trace_data [v ].values
266
266
custom_data_len = len (v ) # number of custom data columns
267
- elif k == "hover_name" :
267
+ elif attr_name == "hover_name" :
268
268
if trace_spec .constructor not in [
269
269
go .Histogram ,
270
270
go .Histogram2d ,
@@ -273,7 +273,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
273
273
result ["hovertext" ] = trace_data [v ]
274
274
if hover_header == "" :
275
275
hover_header = "<b>%{hovertext}</b><br><br>"
276
- elif k == "hover_data" :
276
+ elif attr_name == "hover_data" :
277
277
if trace_spec .constructor not in [
278
278
go .Histogram ,
279
279
go .Histogram2d ,
@@ -296,7 +296,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
296
296
result ["customdata" ] = trace_data [col ].values [:, None ]
297
297
v_label_col = get_decorated_label (args , col , None )
298
298
mapping_labels [v_label_col ] = "%%{customdata[%d]}" % (position )
299
- elif k == "color" :
299
+ elif attr_name == "color" :
300
300
if trace_spec .constructor in [go .Choropleth , go .Choroplethmapbox ]:
301
301
result ["z" ] = trace_data [v ]
302
302
result ["coloraxis" ] = "coloraxis1"
@@ -332,24 +332,24 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
332
332
result [colorable ]["color" ] = trace_data [v ]
333
333
result [colorable ]["coloraxis" ] = "coloraxis1"
334
334
mapping_labels [v_label ] = "%%{%s.color}" % colorable
335
- elif k == "animation_group" :
335
+ elif attr_name == "animation_group" :
336
336
result ["ids" ] = trace_data [v ]
337
- elif k == "locations" :
338
- result [k ] = trace_data [v ]
337
+ elif attr_name == "locations" :
338
+ result [attr_name ] = trace_data [v ]
339
339
mapping_labels [v_label ] = "%{location}"
340
- elif k == "values" :
341
- result [k ] = trace_data [v ]
340
+ elif attr_name == "values" :
341
+ result [attr_name ] = trace_data [v ]
342
342
_label = "value" if v_label == "values" else v_label
343
343
mapping_labels [_label ] = "%{value}"
344
- elif k == "parents" :
345
- result [k ] = trace_data [v ]
344
+ elif attr_name == "parents" :
345
+ result [attr_name ] = trace_data [v ]
346
346
_label = "parent" if v_label == "parents" else v_label
347
347
mapping_labels [_label ] = "%{parent}"
348
- elif k == "ids" :
349
- result [k ] = trace_data [v ]
348
+ elif attr_name == "ids" :
349
+ result [attr_name ] = trace_data [v ]
350
350
_label = "id" if v_label == "ids" else v_label
351
351
mapping_labels [_label ] = "%{id}"
352
- elif k == "names" :
352
+ elif attr_name == "names" :
353
353
if trace_spec .constructor in [
354
354
go .Sunburst ,
355
355
go .Treemap ,
@@ -360,11 +360,11 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
360
360
_label = "label" if v_label == "names" else v_label
361
361
mapping_labels [_label ] = "%{label}"
362
362
else :
363
- result [k ] = trace_data [v ]
363
+ result [attr_name ] = trace_data [v ]
364
364
else :
365
365
if v :
366
- result [k ] = trace_data [v ]
367
- mapping_labels [v_label ] = "%%{%s}" % k
366
+ result [attr_name ] = trace_data [v ]
367
+ mapping_labels [v_label ] = "%%{%s}" % attr_name
368
368
if trace_spec .constructor not in [
369
369
go .Parcoords ,
370
370
go .Parcats ,
0 commit comments