@@ -154,7 +154,7 @@ def get_decorated_label(args, column, role):
154
154
or (role == "y" and "orientation" in args and args ["orientation" ] == "v" )
155
155
):
156
156
histfunc = args ["histfunc" ] or "count"
157
- if label and histfunc != "count" :
157
+ if histfunc != "count" :
158
158
label = "%s of %s" % (histfunc , label )
159
159
else :
160
160
label = "count"
@@ -163,7 +163,10 @@ def get_decorated_label(args, column, role):
163
163
if label == "count" :
164
164
label = args ["histnorm" ]
165
165
else :
166
- label = "%s of %s" % (args ["histnorm" ], label )
166
+ histnorm = args ["histnorm" ]
167
+ # avoid "probability of sum of thing"
168
+ histnorm = "fraction" if histnorm == "probability" else histnorm
169
+ label = "%s of %s" % (histnorm , label )
167
170
168
171
if "barnorm" in args and args ["barnorm" ] is not None :
169
172
label = "%s (normalized as %s)" % (label , args ["barnorm" ])
@@ -1800,6 +1803,14 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1800
1803
):
1801
1804
args ["facet_col_wrap" ] = 0
1802
1805
1806
+ if "norm" in args :
1807
+ if args .get ("norm" , None ) not in [None , "percent" , "probability" ]:
1808
+ raise ValueError (
1809
+ "`norm` must be one of None, 'percent' or 'probability'. "
1810
+ + "'%s' was provided." % args ["norm" ]
1811
+ )
1812
+ args ["histnorm" ] = args ["norm" ]
1813
+
1803
1814
# Compute applicable grouping attributes
1804
1815
for k in group_attrables :
1805
1816
if k in args :
@@ -2027,8 +2038,6 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
2027
2038
group [var ] = group [var ] / group_sum
2028
2039
elif args ["norm" ] == "percent" :
2029
2040
group [var ] = 100.0 * group [var ] / group_sum
2030
- args ["histnorm" ] = args ["norm" ]
2031
- # TODO norm, including histnorm-like naming
2032
2041
2033
2042
patch , fit_results = make_trace_kwargs (
2034
2043
args , trace_spec , group , mapping_labels .copy (), sizeref
0 commit comments