@@ -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
@@ -1917,7 +1917,7 @@ def get_orderings(args, grouper, grouped):
1917
1917
"""
1918
1918
orders = {} if "category_orders" not in args else args ["category_orders" ].copy ()
1919
1919
1920
- if _all_one_group ( grouper ) :
1920
+ if all_same_group :
1921
1921
sorted_group_names = [("" ,) * len (grouper )]
1922
1922
return orders , sorted_group_names
1923
1923
@@ -1944,10 +1944,12 @@ def get_orderings(args, grouper, grouped):
1944
1944
return orders , sorted_group_names
1945
1945
1946
1946
1947
- def _all_one_group ( grouper ):
1948
- for g in grouper :
1947
+ def _all_same_group ( args , grouper ):
1948
+ for g in set ( grouper ) :
1949
1949
if g != one_group :
1950
- return False
1950
+ arr = args ["data_frame" ][g ].values
1951
+ if not (arr [0 ] == arr ).all (axis = 0 ):
1952
+ return False
1951
1953
return True
1952
1954
1953
1955
@@ -1968,10 +1970,11 @@ def make_figure(args, constructor, trace_patch=None, layout_patch=None):
1968
1970
)
1969
1971
grouper = [x .grouper or one_group for x in grouped_mappings ] or [one_group ]
1970
1972
grouped = None
1971
- if not _all_one_group (grouper ):
1973
+ all_same_group = _all_same_group (args , grouper )
1974
+ if not all_same_group :
1972
1975
grouped = args ["data_frame" ].groupby (grouper , sort = False )
1973
1976
1974
- orders , sorted_group_names = get_orderings (args , grouper , grouped )
1977
+ orders , sorted_group_names = get_orderings (args , grouper , grouped , all_same_group )
1975
1978
1976
1979
col_labels = []
1977
1980
row_labels = []
0 commit comments