Skip to content

Commit 9183085

Browse files
tiny refactoring
1 parent 063eb06 commit 9183085

File tree

1 file changed

+9
-14
lines changed
  • packages/python/plotly/plotly/express

1 file changed

+9
-14
lines changed

Diff for: packages/python/plotly/plotly/express/_core.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
264264
mapping_labels["%{xaxis.title.text}"] = "%{x}"
265265
mapping_labels["%{yaxis.title.text}"] = "%{y}"
266266

267-
elif (
268-
attr_value is not None
269-
or (trace_spec.constructor == go.Histogram and attr_name in ["x", "y"])
270-
or (
271-
trace_spec.constructor in [go.Histogram2d, go.Histogram2dContour]
272-
and attr_name == "z"
273-
)
274-
):
267+
elif attr_value is not None:
275268
if attr_name == "size":
276269
if "marker" not in trace_patch:
277270
trace_patch["marker"] = dict()
@@ -464,13 +457,15 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
464457
else:
465458
trace_patch[attr_name] = trace_data[attr_value]
466459
else:
467-
if attr_value:
468-
trace_patch[attr_name] = trace_data[attr_value]
460+
trace_patch[attr_name] = trace_data[attr_value]
469461
mapping_labels[attr_label] = "%%{%s}" % attr_name
470-
if trace_spec.constructor not in [
471-
go.Parcoords,
472-
go.Parcats,
473-
]:
462+
elif (trace_spec.constructor == go.Histogram and attr_name in ["x", "y"]) or (
463+
trace_spec.constructor in [go.Histogram2d, go.Histogram2dContour]
464+
and attr_name == "z"
465+
):
466+
# ensure that stuff like "count" gets into the hoverlabel
467+
mapping_labels[attr_label] = "%%{%s}" % attr_name
468+
if trace_spec.constructor not in [go.Parcoords, go.Parcats]:
474469
# Modify mapping_labels according to hover_data keys
475470
# if hover_data is a dict
476471
mapping_labels_copy = OrderedDict(mapping_labels)

0 commit comments

Comments
 (0)