Skip to content

Commit e7ced12

Browse files
v -> attr_value
1 parent ca87353 commit e7ced12

File tree

1 file changed

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

1 file changed

+27
-27
lines changed

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,20 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
168168
hover_header = ""
169169
custom_data_len = 0
170170
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)
173173
if attr_name == "dimensions":
174174
dims = [
175175
(name, column)
176176
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))
178178
and (
179179
trace_spec.constructor != go.Parcoords
180180
or args["data_frame"][name].dtype.kind in "bifc"
181181
)
182182
and (
183183
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)
185185
or len(args["data_frame"][name].unique())
186186
<= args["dimensions_max_cardinality"]
187187
)
@@ -197,7 +197,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
197197
mapping_labels["%{yaxis.title.text}"] = "%{y}"
198198

199199
elif (
200-
v is not None
200+
attr_value is not None
201201
or (trace_spec.constructor == go.Histogram and attr_name in ["x", "y"])
202202
or (
203203
trace_spec.constructor in [go.Histogram2d, go.Histogram2dContour]
@@ -207,7 +207,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
207207
if attr_name == "size":
208208
if "marker" not in result:
209209
result["marker"] = dict()
210-
result["marker"]["size"] = trace_data[v]
210+
result["marker"]["size"] = trace_data[attr_value]
211211
result["marker"]["sizemode"] = "area"
212212
result["marker"]["sizeref"] = sizeref
213213
mapping_labels[v_label] = "%{marker.size}"
@@ -219,7 +219,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
219219
mapping_labels["count"] = "%{x}"
220220
elif attr_name == "trendline":
221221
if (
222-
v in ["ols", "lowess"]
222+
attr_value in ["ols", "lowess"]
223223
and args["x"]
224224
and args["y"]
225225
and len(trace_data) > 1
@@ -235,11 +235,11 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
235235
if x.dtype.type == np.datetime64:
236236
x = x.astype(int) / 10 ** 9 # convert to unix epoch seconds
237237

238-
if v == "lowess":
238+
if attr_value == "lowess":
239239
trendline = sm.nonparametric.lowess(y, x)
240240
result["y"] = trendline[:, 1]
241241
hover_header = "<b>LOWESS trendline</b><br><br>"
242-
elif v == "ols":
242+
elif attr_value == "ols":
243243
fit_results = sm.OLS(y.values, sm.add_constant(x.values)).fit()
244244
result["y"] = fit_results.predict()
245245
hover_header = "<b>OLS trendline</b><br>"
@@ -260,17 +260,17 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
260260
arr = "arrayminus" if attr_name.endswith("minus") else "array"
261261
if error_xy not in result:
262262
result[error_xy] = {}
263-
result[error_xy][arr] = trace_data[v]
263+
result[error_xy][arr] = trace_data[attr_value]
264264
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
267267
elif attr_name == "hover_name":
268268
if trace_spec.constructor not in [
269269
go.Histogram,
270270
go.Histogram2d,
271271
go.Histogram2dContour,
272272
]:
273-
result["hovertext"] = trace_data[v]
273+
result["hovertext"] = trace_data[attr_value]
274274
if hover_header == "":
275275
hover_header = "<b>%{hovertext}</b><br><br>"
276276
elif attr_name == "hover_data":
@@ -279,7 +279,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
279279
go.Histogram2d,
280280
go.Histogram2dContour,
281281
]:
282-
for col in v:
282+
for col in attr_value:
283283
try:
284284
position = args["custom_data"].index(col)
285285
except (ValueError, AttributeError, KeyError):
@@ -298,7 +298,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
298298
mapping_labels[v_label_col] = "%%{customdata[%d]}" % (position)
299299
elif attr_name == "color":
300300
if trace_spec.constructor in [go.Choropleth, go.Choroplethmapbox]:
301-
result["z"] = trace_data[v]
301+
result["z"] = trace_data[attr_value]
302302
result["coloraxis"] = "coloraxis1"
303303
mapping_labels[v_label] = "%{z}"
304304
elif trace_spec.constructor in [
@@ -311,13 +311,13 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
311311
result["marker"] = dict()
312312

313313
if args.get("color_is_continuous"):
314-
result["marker"]["colors"] = trace_data[v]
314+
result["marker"]["colors"] = trace_data[attr_value]
315315
result["marker"]["coloraxis"] = "coloraxis1"
316316
mapping_labels[v_label] = "%{color}"
317317
else:
318318
result["marker"]["colors"] = []
319319
mapping = {}
320-
for cat in trace_data[v]:
320+
for cat in trace_data[attr_value]:
321321
if mapping.get(cat) is None:
322322
mapping[cat] = args["color_discrete_sequence"][
323323
len(mapping) % len(args["color_discrete_sequence"])
@@ -329,24 +329,24 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
329329
colorable = "line"
330330
if colorable not in result:
331331
result[colorable] = dict()
332-
result[colorable]["color"] = trace_data[v]
332+
result[colorable]["color"] = trace_data[attr_value]
333333
result[colorable]["coloraxis"] = "coloraxis1"
334334
mapping_labels[v_label] = "%%{%s.color}" % colorable
335335
elif attr_name == "animation_group":
336-
result["ids"] = trace_data[v]
336+
result["ids"] = trace_data[attr_value]
337337
elif attr_name == "locations":
338-
result[attr_name] = trace_data[v]
338+
result[attr_name] = trace_data[attr_value]
339339
mapping_labels[v_label] = "%{location}"
340340
elif attr_name == "values":
341-
result[attr_name] = trace_data[v]
341+
result[attr_name] = trace_data[attr_value]
342342
_label = "value" if v_label == "values" else v_label
343343
mapping_labels[_label] = "%{value}"
344344
elif attr_name == "parents":
345-
result[attr_name] = trace_data[v]
345+
result[attr_name] = trace_data[attr_value]
346346
_label = "parent" if v_label == "parents" else v_label
347347
mapping_labels[_label] = "%{parent}"
348348
elif attr_name == "ids":
349-
result[attr_name] = trace_data[v]
349+
result[attr_name] = trace_data[attr_value]
350350
_label = "id" if v_label == "ids" else v_label
351351
mapping_labels[_label] = "%{id}"
352352
elif attr_name == "names":
@@ -356,14 +356,14 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
356356
go.Pie,
357357
go.Funnelarea,
358358
]:
359-
result["labels"] = trace_data[v]
359+
result["labels"] = trace_data[attr_value]
360360
_label = "label" if v_label == "names" else v_label
361361
mapping_labels[_label] = "%{label}"
362362
else:
363-
result[attr_name] = trace_data[v]
363+
result[attr_name] = trace_data[attr_value]
364364
else:
365-
if v:
366-
result[attr_name] = trace_data[v]
365+
if attr_value:
366+
result[attr_name] = trace_data[attr_value]
367367
mapping_labels[v_label] = "%%{%s}" % attr_name
368368
if trace_spec.constructor not in [
369369
go.Parcoords,

0 commit comments

Comments
 (0)