@@ -1904,7 +1904,7 @@ def infer_config(args, constructor, trace_patch, layout_patch):
1904
1904
return trace_specs , grouped_mappings , sizeref , show_colorbar
1905
1905
1906
1906
1907
- def get_orderings (args , grouper , grouped ):
1907
+ def get_orderings (args , grouper , grouped , all_same_group ):
1908
1908
"""
1909
1909
`orders` is the user-supplied ordering with the remaining data-frame-supplied
1910
1910
ordering appended if the column is used for grouping. It includes anything the user
@@ -1916,10 +1916,17 @@ def get_orderings(args, grouper, grouped):
1916
1916
of a single dimension-group
1917
1917
"""
1918
1918
orders = {} if "category_orders" not in args else args ["category_orders" ].copy ()
1919
+ sorted_group_names = []
1919
1920
1920
- if _all_one_group (grouper ):
1921
- sorted_group_names = [("" ,) * len (grouper )]
1922
- return orders , sorted_group_names
1921
+ if all_same_group :
1922
+ for col in grouper :
1923
+ if col != one_group :
1924
+ single_val = args ["data_frame" ][col ].iloc [0 ]
1925
+ sorted_group_names .append (single_val )
1926
+ orders [col ] = [single_val ]
1927
+ else :
1928
+ sorted_group_names .append ("" )
1929
+ return orders , [tuple (sorted_group_names )]
1923
1930
1924
1931
for col in grouper :
1925
1932
if col != one_group :
@@ -1929,7 +1936,6 @@ def get_orderings(args, grouper, grouped):
1929
1936
else :
1930
1937
orders [col ] = list (OrderedDict .fromkeys (list (orders [col ]) + uniques ))
1931
1938
1932
- sorted_group_names = []
1933
1939
for group_name in grouped .groups :
1934
1940
if len (grouper ) == 1 :
1935
1941
group_name = (group_name ,)
@@ -1944,10 +1950,12 @@ def get_orderings(args, grouper, grouped):
1944
1950
return orders , sorted_group_names
1945
1951
1946
1952
1947
- def _all_one_group ( grouper ):
1948
- for g in grouper :
1953
+ def _all_same_group ( args , grouper ):
1954
+ for g in set ( grouper ) :
1949
1955
if g != one_group :
1950
- return False
1956
+ arr = args ["data_frame" ][g ].values
1957
+ if not (arr [0 ] == arr ).all (axis = 0 ):
1958
+ return False
1951
1959
return True
1952
1960
1953
1961
@@ -1968,10 +1976,11 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
1968
1976
)
1969
1977
grouper = [x .grouper or one_group for x in grouped_mappings ] or [one_group ]
1970
1978
grouped = None
1971
- if not _all_one_group (grouper ):
1979
+ all_same_group = _all_same_group (args , grouper )
1980
+ if not all_same_group :
1972
1981
grouped = args ["data_frame" ].groupby (grouper , sort = False )
1973
1982
1974
- orders , sorted_group_names = get_orderings (args , grouper , grouped )
1983
+ orders , sorted_group_names = get_orderings (args , grouper , grouped , all_same_group )
1975
1984
1976
1985
col_labels = []
1977
1986
row_labels = []
0 commit comments