Skip to content

Commit 68ab52a

Browse files
authored
Merge pull request plotly#4 from MarcoGorelli/ecdf-mode-perf
simplify ecdfnorm
2 parents c320c46 + afdb31f commit 68ab52a

File tree

1 file changed

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

1 file changed

+3
-9
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,18 +2638,12 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
26382638
group = group.sort(by=base, descending=False, nulls_last=True)
26392639

26402640
if args.get("ecdfmode", "standard") == "complementary":
2641-
group = group.with_columns(
2642-
((nw.col(var) - nw.lit(group_sum)) * (-1)).alias(var)
2643-
)
2641+
group = group.with_columns((group_sum - nw.col(var)).alias(var))
26442642

26452643
if args["ecdfnorm"] == "probability":
2646-
group = group.with_columns(
2647-
(nw.col(var) / nw.lit(group_sum)).alias(var)
2648-
)
2644+
group = group.with_columns(nw.col(var) / group_sum)
26492645
elif args["ecdfnorm"] == "percent":
2650-
group = group.with_columns(
2651-
(nw.col(var) / nw.lit(group_sum) * nw.lit(100.0)).alias(var)
2652-
)
2646+
group = group.with_columns((nw.col(var) / group_sum) * 100.0)
26532647

26542648
patch, fit_results = make_trace_kwargs(
26552649
args, trace_spec, group, mapping_labels.copy(), sizeref

0 commit comments

Comments
 (0)