@@ -168,20 +168,20 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
168
168
hover_header = ""
169
169
custom_data_len = 0
170
170
for attr_name in trace_spec .attrs :
171
- v = args [attr_name ]
172
- v_label = get_decorated_label (args , v , attr_name )
171
+ attr_value = args [attr_name ]
172
+ v_label = get_decorated_label (args , attr_value , attr_name )
173
173
if attr_name == "dimensions" :
174
174
dims = [
175
175
(name , column )
176
176
for (name , column ) in trace_data .iteritems ()
177
- if ((not v ) or (name in v ))
177
+ if ((not attr_value ) or (name in attr_value ))
178
178
and (
179
179
trace_spec .constructor != go .Parcoords
180
180
or args ["data_frame" ][name ].dtype .kind in "bifc"
181
181
)
182
182
and (
183
183
trace_spec .constructor != go .Parcats
184
- or (v is not None and name in v )
184
+ or (attr_value is not None and name in attr_value )
185
185
or len (args ["data_frame" ][name ].unique ())
186
186
<= args ["dimensions_max_cardinality" ]
187
187
)
@@ -197,7 +197,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
197
197
mapping_labels ["%{yaxis.title.text}" ] = "%{y}"
198
198
199
199
elif (
200
- v is not None
200
+ attr_value is not None
201
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 ]
@@ -207,7 +207,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
207
207
if attr_name == "size" :
208
208
if "marker" not in result :
209
209
result ["marker" ] = dict ()
210
- result ["marker" ]["size" ] = trace_data [v ]
210
+ result ["marker" ]["size" ] = trace_data [attr_value ]
211
211
result ["marker" ]["sizemode" ] = "area"
212
212
result ["marker" ]["sizeref" ] = sizeref
213
213
mapping_labels [v_label ] = "%{marker.size}"
@@ -219,7 +219,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
219
219
mapping_labels ["count" ] = "%{x}"
220
220
elif attr_name == "trendline" :
221
221
if (
222
- v in ["ols" , "lowess" ]
222
+ attr_value in ["ols" , "lowess" ]
223
223
and args ["x" ]
224
224
and args ["y" ]
225
225
and len (trace_data ) > 1
@@ -235,11 +235,11 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
235
235
if x .dtype .type == np .datetime64 :
236
236
x = x .astype (int ) / 10 ** 9 # convert to unix epoch seconds
237
237
238
- if v == "lowess" :
238
+ if attr_value == "lowess" :
239
239
trendline = sm .nonparametric .lowess (y , x )
240
240
result ["y" ] = trendline [:, 1 ]
241
241
hover_header = "<b>LOWESS trendline</b><br><br>"
242
- elif v == "ols" :
242
+ elif attr_value == "ols" :
243
243
fit_results = sm .OLS (y .values , sm .add_constant (x .values )).fit ()
244
244
result ["y" ] = fit_results .predict ()
245
245
hover_header = "<b>OLS trendline</b><br>"
@@ -260,17 +260,17 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
260
260
arr = "arrayminus" if attr_name .endswith ("minus" ) else "array"
261
261
if error_xy not in result :
262
262
result [error_xy ] = {}
263
- result [error_xy ][arr ] = trace_data [v ]
263
+ result [error_xy ][arr ] = trace_data [attr_value ]
264
264
elif attr_name == "custom_data" :
265
- result ["customdata" ] = trace_data [v ].values
266
- custom_data_len = len (v ) # number of custom data columns
265
+ result ["customdata" ] = trace_data [attr_value ].values
266
+ custom_data_len = len (attr_value ) # number of custom data columns
267
267
elif attr_name == "hover_name" :
268
268
if trace_spec .constructor not in [
269
269
go .Histogram ,
270
270
go .Histogram2d ,
271
271
go .Histogram2dContour ,
272
272
]:
273
- result ["hovertext" ] = trace_data [v ]
273
+ result ["hovertext" ] = trace_data [attr_value ]
274
274
if hover_header == "" :
275
275
hover_header = "<b>%{hovertext}</b><br><br>"
276
276
elif attr_name == "hover_data" :
@@ -279,7 +279,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
279
279
go .Histogram2d ,
280
280
go .Histogram2dContour ,
281
281
]:
282
- for col in v :
282
+ for col in attr_value :
283
283
try :
284
284
position = args ["custom_data" ].index (col )
285
285
except (ValueError , AttributeError , KeyError ):
@@ -298,7 +298,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
298
298
mapping_labels [v_label_col ] = "%%{customdata[%d]}" % (position )
299
299
elif attr_name == "color" :
300
300
if trace_spec .constructor in [go .Choropleth , go .Choroplethmapbox ]:
301
- result ["z" ] = trace_data [v ]
301
+ result ["z" ] = trace_data [attr_value ]
302
302
result ["coloraxis" ] = "coloraxis1"
303
303
mapping_labels [v_label ] = "%{z}"
304
304
elif trace_spec .constructor in [
@@ -311,13 +311,13 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
311
311
result ["marker" ] = dict ()
312
312
313
313
if args .get ("color_is_continuous" ):
314
- result ["marker" ]["colors" ] = trace_data [v ]
314
+ result ["marker" ]["colors" ] = trace_data [attr_value ]
315
315
result ["marker" ]["coloraxis" ] = "coloraxis1"
316
316
mapping_labels [v_label ] = "%{color}"
317
317
else :
318
318
result ["marker" ]["colors" ] = []
319
319
mapping = {}
320
- for cat in trace_data [v ]:
320
+ for cat in trace_data [attr_value ]:
321
321
if mapping .get (cat ) is None :
322
322
mapping [cat ] = args ["color_discrete_sequence" ][
323
323
len (mapping ) % len (args ["color_discrete_sequence" ])
@@ -329,24 +329,24 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
329
329
colorable = "line"
330
330
if colorable not in result :
331
331
result [colorable ] = dict ()
332
- result [colorable ]["color" ] = trace_data [v ]
332
+ result [colorable ]["color" ] = trace_data [attr_value ]
333
333
result [colorable ]["coloraxis" ] = "coloraxis1"
334
334
mapping_labels [v_label ] = "%%{%s.color}" % colorable
335
335
elif attr_name == "animation_group" :
336
- result ["ids" ] = trace_data [v ]
336
+ result ["ids" ] = trace_data [attr_value ]
337
337
elif attr_name == "locations" :
338
- result [attr_name ] = trace_data [v ]
338
+ result [attr_name ] = trace_data [attr_value ]
339
339
mapping_labels [v_label ] = "%{location}"
340
340
elif attr_name == "values" :
341
- result [attr_name ] = trace_data [v ]
341
+ result [attr_name ] = trace_data [attr_value ]
342
342
_label = "value" if v_label == "values" else v_label
343
343
mapping_labels [_label ] = "%{value}"
344
344
elif attr_name == "parents" :
345
- result [attr_name ] = trace_data [v ]
345
+ result [attr_name ] = trace_data [attr_value ]
346
346
_label = "parent" if v_label == "parents" else v_label
347
347
mapping_labels [_label ] = "%{parent}"
348
348
elif attr_name == "ids" :
349
- result [attr_name ] = trace_data [v ]
349
+ result [attr_name ] = trace_data [attr_value ]
350
350
_label = "id" if v_label == "ids" else v_label
351
351
mapping_labels [_label ] = "%{id}"
352
352
elif attr_name == "names" :
@@ -356,14 +356,14 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
356
356
go .Pie ,
357
357
go .Funnelarea ,
358
358
]:
359
- result ["labels" ] = trace_data [v ]
359
+ result ["labels" ] = trace_data [attr_value ]
360
360
_label = "label" if v_label == "names" else v_label
361
361
mapping_labels [_label ] = "%{label}"
362
362
else :
363
- result [attr_name ] = trace_data [v ]
363
+ result [attr_name ] = trace_data [attr_value ]
364
364
else :
365
- if v :
366
- result [attr_name ] = trace_data [v ]
365
+ if attr_value :
366
+ result [attr_name ] = trace_data [attr_value ]
367
367
mapping_labels [v_label ] = "%%{%s}" % attr_name
368
368
if trace_spec .constructor not in [
369
369
go .Parcoords ,
0 commit comments