@@ -1316,6 +1316,9 @@ def build_dataframe(args, constructor):
1316
1316
wide_cross_name = None # will likely be "index" in wide_mode
1317
1317
value_name = None # will likely be "value" in wide_mode
1318
1318
hist2d_types = [go .Histogram2d , go .Histogram2dContour ]
1319
+ hist1d_orientation = (
1320
+ constructor == go .Histogram or "complementary" in args or "kernel" in args
1321
+ )
1319
1322
if constructor in cartesians :
1320
1323
if wide_x and wide_y :
1321
1324
raise ValueError (
@@ -1350,7 +1353,7 @@ def build_dataframe(args, constructor):
1350
1353
df_provided and var_name in df_input
1351
1354
):
1352
1355
var_name = "variable"
1353
- if constructor == go . Histogram :
1356
+ if hist1d_orientation :
1354
1357
wide_orientation = "v" if wide_x else "h"
1355
1358
else :
1356
1359
wide_orientation = "v" if wide_y else "h"
@@ -1364,7 +1367,10 @@ def build_dataframe(args, constructor):
1364
1367
var_name = _escape_col_name (df_input , var_name , [])
1365
1368
1366
1369
missing_bar_dim = None
1367
- if constructor in [go .Scatter , go .Bar , go .Funnel ] + hist2d_types :
1370
+ if (
1371
+ constructor in [go .Scatter , go .Bar , go .Funnel ] + hist2d_types
1372
+ and not hist1d_orientation
1373
+ ):
1368
1374
if not wide_mode and (no_x != no_y ):
1369
1375
for ax in ["x" , "y" ]:
1370
1376
if args .get (ax ) is None :
@@ -1461,14 +1467,22 @@ def build_dataframe(args, constructor):
1461
1467
df_output [var_name ] = df_output [var_name ].astype (str )
1462
1468
orient_v = wide_orientation == "v"
1463
1469
1464
- if constructor in [go .Scatter , go .Funnel ] + hist2d_types :
1470
+ if hist1d_orientation :
1471
+ args ["x" if orient_v else "y" ] = value_name
1472
+ if wide_cross_name is None and constructor == go .Scatter :
1473
+ args ["y" if orient_v else "x" ] = count_name
1474
+ df_output [count_name ] = 1
1475
+ else :
1476
+ args ["y" if orient_v else "x" ] = wide_cross_name
1477
+ args ["color" ] = args ["color" ] or var_name
1478
+ elif constructor in [go .Scatter , go .Funnel ] + hist2d_types :
1465
1479
args ["x" if orient_v else "y" ] = wide_cross_name
1466
1480
args ["y" if orient_v else "x" ] = value_name
1467
1481
if constructor != go .Histogram2d :
1468
1482
args ["color" ] = args ["color" ] or var_name
1469
1483
if "line_group" in args :
1470
1484
args ["line_group" ] = args ["line_group" ] or var_name
1471
- if constructor == go .Bar :
1485
+ elif constructor == go .Bar :
1472
1486
if _is_continuous (df_output , value_name ):
1473
1487
args ["x" if orient_v else "y" ] = wide_cross_name
1474
1488
args ["y" if orient_v else "x" ] = value_name
@@ -1478,13 +1492,9 @@ def build_dataframe(args, constructor):
1478
1492
args ["y" if orient_v else "x" ] = count_name
1479
1493
df_output [count_name ] = 1
1480
1494
args ["color" ] = args ["color" ] or var_name
1481
- if constructor in [go .Violin , go .Box ]:
1495
+ elif constructor in [go .Violin , go .Box ]:
1482
1496
args ["x" if orient_v else "y" ] = wide_cross_name or var_name
1483
1497
args ["y" if orient_v else "x" ] = value_name
1484
- if constructor == go .Histogram :
1485
- args ["x" if orient_v else "y" ] = value_name
1486
- args ["y" if orient_v else "x" ] = wide_cross_name
1487
- args ["color" ] = args ["color" ] or var_name
1488
1498
if no_color :
1489
1499
args ["color" ] = None
1490
1500
args ["data_frame" ] = df_output
@@ -1973,11 +1983,11 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
1973
1983
trace_spec != trace_specs [0 ]
1974
1984
and (
1975
1985
trace_spec .constructor in [go .Violin , go .Box ]
1976
- and m .variable in ["symbol" , "pattern" ]
1986
+ and m .variable in ["symbol" , "pattern" , "dash" ]
1977
1987
)
1978
1988
or (
1979
1989
trace_spec .constructor in [go .Histogram ]
1980
- and m .variable in ["symbol" ]
1990
+ and m .variable in ["symbol" , "dash" ]
1981
1991
)
1982
1992
):
1983
1993
pass
@@ -2036,6 +2046,12 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
2036
2046
):
2037
2047
trace .update (marker = dict (color = trace .line .color ))
2038
2048
2049
+ if "complementary" in args : # ECDF
2050
+ base = args ["x" ] if args ["orientation" ] == "v" else args ["y" ]
2051
+ var = args ["x" ] if args ["orientation" ] == "h" else args ["y" ]
2052
+ group = group .sort_values (by = base )
2053
+ group [var ] = group [var ].cumsum ()
2054
+
2039
2055
patch , fit_results = make_trace_kwargs (
2040
2056
args , trace_spec , group , mapping_labels .copy (), sizeref
2041
2057
)
0 commit comments