diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py index fb195ba6a8..8f6c20a17d 100644 --- a/packages/python/plotly/plotly/express/_core.py +++ b/packages/python/plotly/plotly/express/_core.py @@ -1813,6 +1813,14 @@ def infer_config(args, constructor, trace_patch, layout_patch): ): args["facet_col_wrap"] = 0 + if "norm" in args: + if args.get("norm", None) not in [None, "percent", "probability"]: + raise ValueError( + "`norm` must be one of None, 'percent' or 'probability'. " + + "'%s' was provided." % args["norm"] + ) + args["histnorm"] = args["norm"] + # Compute applicable grouping attributes for k in group_attrables: if k in args: @@ -2040,8 +2048,6 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None): group[var] = group[var] / group_sum elif args["norm"] == "percent": group[var] = 100.0 * group[var] / group_sum - args["histnorm"] = args["norm"] - # TODO norm, including histnorm-like naming patch, fit_results = make_trace_kwargs( args, trace_spec, group, mapping_labels.copy(), sizeref