@@ -149,16 +149,22 @@ def _is_continuous(df, col_name):
149
149
def get_decorated_label (args , column , role ):
150
150
label = get_label (args , column )
151
151
if "histfunc" in args and (
152
- (role == "x" and "orientation" in args and args ["orientation" ] == "h" )
152
+ (role == "z" )
153
+ or (role == "x" and "orientation" in args and args ["orientation" ] == "h" )
153
154
or (role == "y" and "orientation" in args and args ["orientation" ] == "v" )
154
- or (role == "z" )
155
155
):
156
156
if label :
157
- return "%s of %s" % (args ["histfunc" ] or "count" , label )
157
+ label = "%s of %s" % (args ["histfunc" ] or "count" , label )
158
158
else :
159
- return "count"
160
- else :
161
- return label
159
+ label = "count"
160
+
161
+ if "histnorm" in args and args ["histnorm" ] is not None :
162
+ label = "%s of %s" % (args ["histnorm" ], label )
163
+
164
+ if "barnorm" in args and args ["barnorm" ] is not None :
165
+ label = "%s (normalized as %s)" % (label , args ["barnorm" ])
166
+
167
+ return label
162
168
163
169
164
170
def make_mapping (args , variable ):
@@ -264,14 +270,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
264
270
mapping_labels ["%{xaxis.title.text}" ] = "%{x}"
265
271
mapping_labels ["%{yaxis.title.text}" ] = "%{y}"
266
272
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
- ):
273
+ elif attr_value is not None :
275
274
if attr_name == "size" :
276
275
if "marker" not in trace_patch :
277
276
trace_patch ["marker" ] = dict ()
@@ -464,13 +463,15 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
464
463
else :
465
464
trace_patch [attr_name ] = trace_data [attr_value ]
466
465
else :
467
- if attr_value :
468
- trace_patch [attr_name ] = trace_data [attr_value ]
466
+ trace_patch [attr_name ] = trace_data [attr_value ]
469
467
mapping_labels [attr_label ] = "%%{%s}" % attr_name
470
- if trace_spec .constructor not in [
471
- go .Parcoords ,
472
- go .Parcats ,
473
- ]:
468
+ elif (trace_spec .constructor == go .Histogram and attr_name in ["x" , "y" ]) or (
469
+ trace_spec .constructor in [go .Histogram2d , go .Histogram2dContour ]
470
+ and attr_name == "z"
471
+ ):
472
+ # ensure that stuff like "count" gets into the hoverlabel
473
+ mapping_labels [attr_label ] = "%%{%s}" % attr_name
474
+ if trace_spec .constructor not in [go .Parcoords , go .Parcats ]:
474
475
# Modify mapping_labels according to hover_data keys
475
476
# if hover_data is a dict
476
477
mapping_labels_copy = OrderedDict (mapping_labels )
0 commit comments