Skip to content

Commit ca87353

Browse files
k -> attr_name
1 parent e9fa00d commit ca87353

File tree

1 file changed

+30
-30
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+30
-30
lines changed

packages/python/plotly/plotly/express/_core.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
167167
fit_results = None
168168
hover_header = ""
169169
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":
174174
dims = [
175175
(name, column)
176176
for (name, column) in trace_data.iteritems()
@@ -198,26 +198,26 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
198198

199199
elif (
200200
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"])
202202
or (
203203
trace_spec.constructor in [go.Histogram2d, go.Histogram2dContour]
204-
and k == "z"
204+
and attr_name == "z"
205205
)
206206
):
207-
if k == "size":
207+
if attr_name == "size":
208208
if "marker" not in result:
209209
result["marker"] = dict()
210210
result["marker"]["size"] = trace_data[v]
211211
result["marker"]["sizemode"] = "area"
212212
result["marker"]["sizeref"] = sizeref
213213
mapping_labels[v_label] = "%{marker.size}"
214-
elif k == "marginal_x":
214+
elif attr_name == "marginal_x":
215215
if trace_spec.constructor == go.Histogram:
216216
mapping_labels["count"] = "%{y}"
217-
elif k == "marginal_y":
217+
elif attr_name == "marginal_y":
218218
if trace_spec.constructor == go.Histogram:
219219
mapping_labels["count"] = "%{x}"
220-
elif k == "trendline":
220+
elif attr_name == "trendline":
221221
if (
222222
v in ["ols", "lowess"]
223223
and args["x"]
@@ -255,16 +255,16 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
255255
mapping_labels[get_label(args, args["x"])] = "%{x}"
256256
mapping_labels[get_label(args, args["y"])] = "%{y} <b>(trend)</b>"
257257

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"
261261
if error_xy not in result:
262262
result[error_xy] = {}
263263
result[error_xy][arr] = trace_data[v]
264-
elif k == "custom_data":
264+
elif attr_name == "custom_data":
265265
result["customdata"] = trace_data[v].values
266266
custom_data_len = len(v) # number of custom data columns
267-
elif k == "hover_name":
267+
elif attr_name == "hover_name":
268268
if trace_spec.constructor not in [
269269
go.Histogram,
270270
go.Histogram2d,
@@ -273,7 +273,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
273273
result["hovertext"] = trace_data[v]
274274
if hover_header == "":
275275
hover_header = "<b>%{hovertext}</b><br><br>"
276-
elif k == "hover_data":
276+
elif attr_name == "hover_data":
277277
if trace_spec.constructor not in [
278278
go.Histogram,
279279
go.Histogram2d,
@@ -296,7 +296,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
296296
result["customdata"] = trace_data[col].values[:, None]
297297
v_label_col = get_decorated_label(args, col, None)
298298
mapping_labels[v_label_col] = "%%{customdata[%d]}" % (position)
299-
elif k == "color":
299+
elif attr_name == "color":
300300
if trace_spec.constructor in [go.Choropleth, go.Choroplethmapbox]:
301301
result["z"] = trace_data[v]
302302
result["coloraxis"] = "coloraxis1"
@@ -332,24 +332,24 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
332332
result[colorable]["color"] = trace_data[v]
333333
result[colorable]["coloraxis"] = "coloraxis1"
334334
mapping_labels[v_label] = "%%{%s.color}" % colorable
335-
elif k == "animation_group":
335+
elif attr_name == "animation_group":
336336
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]
339339
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]
342342
_label = "value" if v_label == "values" else v_label
343343
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]
346346
_label = "parent" if v_label == "parents" else v_label
347347
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]
350350
_label = "id" if v_label == "ids" else v_label
351351
mapping_labels[_label] = "%{id}"
352-
elif k == "names":
352+
elif attr_name == "names":
353353
if trace_spec.constructor in [
354354
go.Sunburst,
355355
go.Treemap,
@@ -360,11 +360,11 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
360360
_label = "label" if v_label == "names" else v_label
361361
mapping_labels[_label] = "%{label}"
362362
else:
363-
result[k] = trace_data[v]
363+
result[attr_name] = trace_data[v]
364364
else:
365365
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
368368
if trace_spec.constructor not in [
369369
go.Parcoords,
370370
go.Parcats,

0 commit comments

Comments
 (0)