@@ -1275,6 +1275,9 @@ def build_dataframe(args, constructor):
1275
1275
wide_cross_name = None # will likely be "index" in wide_mode
1276
1276
value_name = None # will likely be "value" in wide_mode
1277
1277
hist2d_types = [go .Histogram2d , go .Histogram2dContour ]
1278
+ hist1d_orientation = (
1279
+ constructor == go .Histogram or "complementary" in args or "kernel" in args
1280
+ )
1278
1281
if constructor in cartesians :
1279
1282
if wide_x and wide_y :
1280
1283
raise ValueError (
@@ -1309,7 +1312,7 @@ def build_dataframe(args, constructor):
1309
1312
df_provided and var_name in df_input
1310
1313
):
1311
1314
var_name = "variable"
1312
- if constructor == go . Histogram :
1315
+ if hist1d_orientation :
1313
1316
wide_orientation = "v" if wide_x else "h"
1314
1317
else :
1315
1318
wide_orientation = "v" if wide_y else "h"
@@ -1323,7 +1326,10 @@ def build_dataframe(args, constructor):
1323
1326
var_name = _escape_col_name (df_input , var_name , [])
1324
1327
1325
1328
missing_bar_dim = None
1326
- if constructor in [go .Scatter , go .Bar , go .Funnel ] + hist2d_types :
1329
+ if (
1330
+ constructor in [go .Scatter , go .Bar , go .Funnel ] + hist2d_types
1331
+ and not hist1d_orientation
1332
+ ):
1327
1333
if not wide_mode and (no_x != no_y ):
1328
1334
for ax in ["x" , "y" ]:
1329
1335
if args .get (ax , None ) is None :
@@ -1420,14 +1426,22 @@ def build_dataframe(args, constructor):
1420
1426
df_output [var_name ] = df_output [var_name ].astype (str )
1421
1427
orient_v = wide_orientation == "v"
1422
1428
1423
- if constructor in [go .Scatter , go .Funnel ] + hist2d_types :
1429
+ if hist1d_orientation :
1430
+ args ["x" if orient_v else "y" ] = value_name
1431
+ if wide_cross_name is None and constructor == go .Scatter :
1432
+ args ["y" if orient_v else "x" ] = count_name
1433
+ df_output [count_name ] = 1
1434
+ else :
1435
+ args ["y" if orient_v else "x" ] = wide_cross_name
1436
+ args ["color" ] = args ["color" ] or var_name
1437
+ elif constructor in [go .Scatter , go .Funnel ] + hist2d_types :
1424
1438
args ["x" if orient_v else "y" ] = wide_cross_name
1425
1439
args ["y" if orient_v else "x" ] = value_name
1426
1440
if constructor != go .Histogram2d :
1427
1441
args ["color" ] = args ["color" ] or var_name
1428
1442
if "line_group" in args :
1429
1443
args ["line_group" ] = args ["line_group" ] or var_name
1430
- if constructor == go .Bar :
1444
+ elif constructor == go .Bar :
1431
1445
if _is_continuous (df_output , value_name ):
1432
1446
args ["x" if orient_v else "y" ] = wide_cross_name
1433
1447
args ["y" if orient_v else "x" ] = value_name
@@ -1437,13 +1451,9 @@ def build_dataframe(args, constructor):
1437
1451
args ["y" if orient_v else "x" ] = count_name
1438
1452
df_output [count_name ] = 1
1439
1453
args ["color" ] = args ["color" ] or var_name
1440
- if constructor in [go .Violin , go .Box ]:
1454
+ elif constructor in [go .Violin , go .Box ]:
1441
1455
args ["x" if orient_v else "y" ] = wide_cross_name or var_name
1442
1456
args ["y" if orient_v else "x" ] = value_name
1443
- if constructor == go .Histogram :
1444
- args ["x" if orient_v else "y" ] = value_name
1445
- args ["y" if orient_v else "x" ] = wide_cross_name
1446
- args ["color" ] = args ["color" ] or var_name
1447
1457
if no_color :
1448
1458
args ["color" ] = None
1449
1459
args ["data_frame" ] = df_output
@@ -1925,7 +1935,7 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
1925
1935
if (
1926
1936
trace_spec != trace_specs [0 ]
1927
1937
and trace_spec .constructor in [go .Violin , go .Box , go .Histogram ]
1928
- and m .variable == "symbol"
1938
+ and m .variable in [ "symbol" , "dash" ]
1929
1939
):
1930
1940
pass
1931
1941
elif (
@@ -1986,6 +1996,12 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
1986
1996
):
1987
1997
trace .update (marker = dict (color = trace .line .color ))
1988
1998
1999
+ if "complementary" in args : # ECDF
2000
+ base = args ["x" ] if args ["orientation" ] == "v" else args ["y" ]
2001
+ var = args ["x" ] if args ["orientation" ] == "h" else args ["y" ]
2002
+ group = group .sort_values (by = base )
2003
+ group [var ] = group [var ].cumsum ()
2004
+
1989
2005
patch , fit_results = make_trace_kwargs (
1990
2006
args , trace_spec , group , mapping_labels .copy (), sizeref
1991
2007
)
0 commit comments