@@ -149,16 +149,22 @@ def _is_continuous(df, col_name):
149149def get_decorated_label (args , column , role ):
150150 label = get_label (args , column )
151151 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" )
153154 or (role == "y" and "orientation" in args and args ["orientation" ] == "v" )
154- or (role == "z" )
155155 ):
156156 if label :
157- return "%s of %s" % (args ["histfunc" ] or "count" , label )
157+ label = "%s of %s" % (args ["histfunc" ] or "count" , label )
158158 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
162168
163169
164170def make_mapping (args , variable ):
@@ -264,14 +270,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
264270 mapping_labels ["%{xaxis.title.text}" ] = "%{x}"
265271 mapping_labels ["%{yaxis.title.text}" ] = "%{y}"
266272
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 :
275274 if attr_name == "size" :
276275 if "marker" not in trace_patch :
277276 trace_patch ["marker" ] = dict ()
@@ -464,13 +463,15 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
464463 else :
465464 trace_patch [attr_name ] = trace_data [attr_value ]
466465 else :
467- if attr_value :
468- trace_patch [attr_name ] = trace_data [attr_value ]
466+ trace_patch [attr_name ] = trace_data [attr_value ]
469467 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 ]:
474475 # Modify mapping_labels according to hover_data keys
475476 # if hover_data is a dict
476477 mapping_labels_copy = OrderedDict (mapping_labels )
0 commit comments