@@ -153,13 +153,17 @@ def get_decorated_label(args, column, role):
153
153
or (role == "x" and "orientation" in args and args ["orientation" ] == "h" )
154
154
or (role == "y" and "orientation" in args and args ["orientation" ] == "v" )
155
155
):
156
- if label :
157
- label = "%s of %s" % (args ["histfunc" ] or "count" , label )
156
+ histfunc = args ["histfunc" ] or "count"
157
+ if label and histfunc != "count" :
158
+ label = "%s of %s" % (histfunc , label )
158
159
else :
159
160
label = "count"
160
161
161
162
if "histnorm" in args and args ["histnorm" ] is not None :
162
- label = "%s of %s" % (args ["histnorm" ], label )
163
+ if label == "count" :
164
+ label = args ["histnorm" ]
165
+ else :
166
+ label = "%s of %s" % (args ["histnorm" ], label )
163
167
164
168
if "barnorm" in args and args ["barnorm" ] is not None :
165
169
label = "%s (normalized as %s)" % (label , args ["barnorm" ])
@@ -1421,11 +1425,7 @@ def build_dataframe(args, constructor):
1421
1425
1422
1426
if hist1d_orientation :
1423
1427
args ["x" if orient_v else "y" ] = value_name
1424
- if wide_cross_name is None and constructor == go .Scatter :
1425
- args ["y" if orient_v else "x" ] = count_name
1426
- df_output [count_name ] = 1
1427
- else :
1428
- args ["y" if orient_v else "x" ] = wide_cross_name
1428
+ args ["y" if orient_v else "x" ] = wide_cross_name
1429
1429
args ["color" ] = args ["color" ] or var_name
1430
1430
elif constructor in [go .Scatter , go .Funnel ] + hist2d_types :
1431
1431
args ["x" if orient_v else "y" ] = wide_cross_name
@@ -1447,6 +1447,21 @@ def build_dataframe(args, constructor):
1447
1447
elif constructor in [go .Violin , go .Box ]:
1448
1448
args ["x" if orient_v else "y" ] = wide_cross_name or var_name
1449
1449
args ["y" if orient_v else "x" ] = value_name
1450
+
1451
+ if hist1d_orientation and constructor == go .Scatter :
1452
+ if args ["x" ] is not None and args ["y" ] is not None :
1453
+ args ["histfunc" ] = "sum"
1454
+ elif args ["x" ] is None :
1455
+ args ["histfunc" ] = None
1456
+ args ["orientation" ] = "h"
1457
+ args ["x" ] = count_name
1458
+ df_output [count_name ] = 1
1459
+ else :
1460
+ args ["histfunc" ] = None
1461
+ args ["orientation" ] = "v"
1462
+ args ["y" ] = count_name
1463
+ df_output [count_name ] = 1
1464
+
1450
1465
if no_color :
1451
1466
args ["color" ] = None
1452
1467
args ["data_frame" ] = df_output
@@ -1743,8 +1758,10 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1743
1758
trace_patch ["opacity" ] = args ["opacity" ]
1744
1759
else :
1745
1760
trace_patch ["marker" ] = dict (opacity = args ["opacity" ])
1746
- if "line_group" in args :
1747
- trace_patch ["mode" ] = "lines" + ("+markers+text" if args ["text" ] else "" )
1761
+ if "line_group" in args or "line_dash" in args :
1762
+ trace_patch ["mode" ] = "lines" + (
1763
+ "+markers+text" if args .get ("text" , None ) is not None else ""
1764
+ )
1748
1765
elif constructor != go .Splom and (
1749
1766
"symbol" in args or constructor == go .Scattermapbox
1750
1767
):
@@ -2001,7 +2018,17 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
2001
2018
base = args ["x" ] if args ["orientation" ] == "v" else args ["y" ]
2002
2019
var = args ["x" ] if args ["orientation" ] == "h" else args ["y" ]
2003
2020
group = group .sort_values (by = base )
2021
+ group_sum = group [var ].sum ()
2004
2022
group [var ] = group [var ].cumsum ()
2023
+ if args ["complementary" ]:
2024
+ group [var ] = group_sum - group [var ]
2025
+
2026
+ if args ["norm" ] == "probability" :
2027
+ group [var ] = group [var ] / group_sum
2028
+ elif args ["norm" ] == "percent" :
2029
+ group [var ] = 100.0 * group [var ] / group_sum
2030
+ args ["histnorm" ] = args ["norm" ]
2031
+ # TODO norm, including histnorm-like naming
2005
2032
2006
2033
patch , fit_results = make_trace_kwargs (
2007
2034
args , trace_spec , group , mapping_labels .copy (), sizeref
0 commit comments