@@ -1898,6 +1898,7 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1898
1898
1899
1899
# Create grouped mappings
1900
1900
grouped_mappings = [make_mapping (args , a ) for a in grouped_attrs ]
1901
+ grouped_mappings = [x for x in grouped_mappings if x .grouper ]
1901
1902
1902
1903
# Create trace specs
1903
1904
trace_specs = make_trace_spec (args , constructor , attrs , trace_patch )
@@ -1915,15 +1916,18 @@ def get_orderings(args, grouper, grouped):
1915
1916
of tuples like [("value1", ""), ("value2", "")] where each tuple contains the name
1916
1917
of a single dimension-group
1917
1918
"""
1918
-
1919
1919
orders = {} if "category_orders" not in args else args ["category_orders" ].copy ()
1920
+
1921
+ if grouper == [one_group ]:
1922
+ sorted_group_names = [("" ,)]
1923
+ return orders , sorted_group_names
1924
+
1920
1925
for col in grouper :
1921
- if col != one_group :
1922
- uniques = list (args ["data_frame" ][col ].unique ())
1923
- if col not in orders :
1924
- orders [col ] = uniques
1925
- else :
1926
- orders [col ] = list (OrderedDict .fromkeys (list (orders [col ]) + uniques ))
1926
+ uniques = list (args ["data_frame" ][col ].unique ())
1927
+ if col not in orders :
1928
+ orders [col ] = uniques
1929
+ else :
1930
+ orders [col ] = list (OrderedDict .fromkeys (list (orders [col ]) + uniques ))
1927
1931
1928
1932
sorted_group_names = []
1929
1933
for group_name in grouped .groups :
@@ -1932,11 +1936,10 @@ def get_orderings(args, grouper, grouped):
1932
1936
sorted_group_names .append (group_name )
1933
1937
1934
1938
for i , col in reversed (list (enumerate (grouper ))):
1935
- if col != one_group :
1936
- sorted_group_names = sorted (
1937
- sorted_group_names ,
1938
- key = lambda g : orders [col ].index (g [i ]) if g [i ] in orders [col ] else - 1 ,
1939
- )
1939
+ sorted_group_names = sorted (
1940
+ sorted_group_names ,
1941
+ key = lambda g : orders [col ].index (g [i ]) if g [i ] in orders [col ] else - 1 ,
1942
+ )
1940
1943
return orders , sorted_group_names
1941
1944
1942
1945
@@ -1955,8 +1958,12 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
1955
1958
trace_specs , grouped_mappings , sizeref , show_colorbar = infer_config (
1956
1959
args , constructor , trace_patch , layout_patch
1957
1960
)
1958
- grouper = [x .grouper or one_group for x in grouped_mappings ] or [one_group ]
1959
- grouped = args ["data_frame" ].groupby (grouper , sort = False )
1961
+ if len (grouped_mappings ):
1962
+ grouper = [x .grouper for x in grouped_mappings ]
1963
+ grouped = args ["data_frame" ].groupby (grouper , sort = False )
1964
+ else :
1965
+ grouper = [one_group ]
1966
+ grouped = None
1960
1967
1961
1968
orders , sorted_group_names = get_orderings (args , grouper , grouped )
1962
1969
@@ -1988,7 +1995,12 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
1988
1995
trace_name_labels = None
1989
1996
facet_col_wrap = args .get ("facet_col_wrap" , 0 )
1990
1997
for group_name in sorted_group_names :
1991
- group = grouped .get_group (group_name if len (group_name ) > 1 else group_name [0 ])
1998
+ if grouped is not None :
1999
+ group = grouped .get_group (
2000
+ group_name if len (group_name ) > 1 else group_name [0 ]
2001
+ )
2002
+ else :
2003
+ group = args ["data_frame" ]
1992
2004
mapping_labels = OrderedDict ()
1993
2005
trace_name_labels = OrderedDict ()
1994
2006
frame_name = ""
0 commit comments