@@ -3049,7 +3049,7 @@ def broken_barh(self, xranges, yrange, **kwargs):
30493049 return col
30503050
30513051 def grouped_bar (self , x , heights , * , group_spacing = 1.5 , bar_spacing = 0 ,
3052- dataset_labels = None , orientation = "vertical" , colors = None ,
3052+ labels = None , orientation = "vertical" , colors = None ,
30533053 ** kwargs ):
30543054 """
30553055 Make a grouped bar plot.
@@ -3119,8 +3119,12 @@ def grouped_bar(self, x, heights, *, group_spacing=1.5, bar_spacing=0,
31193119 bar_spacing : float
31203120 The space between bars in units of bar width.
31213121
3122- dataset_labels : array-like of str, optional
3123- The labels of the datasets.
3122+ labels : array-like of str, optional
3123+ The labels of the datasets, i.e. the bars within one group.
3124+ These will show up in the legend.
3125+
3126+ Note: The "other" label dimension are the group labels, which
3127+ can be set via *x*.
31243128
31253129 orientation : {"vertical", "horizontal"}, default: vertical
31263130
@@ -3138,10 +3142,10 @@ def grouped_bar(self, x, heights, *, group_spacing=1.5, bar_spacing=0,
31383142
31393143 """
31403144 if hasattr (heights , 'keys' ):
3141- if dataset_labels is not None :
3145+ if labels is not None :
31423146 raise ValueError (
3143- "'dataset_labels ' cannot be used if 'heights' are a mapping" )
3144- dataset_labels = heights .keys ()
3147+ "'labels ' cannot be used if 'heights' are a mapping" )
3148+ labels = heights .keys ()
31453149 heights = heights .values ()
31463150 elif hasattr (heights , 'shape' ):
31473151 heights = heights .T
@@ -3185,23 +3189,23 @@ def grouped_bar(self, x, heights, *, group_spacing=1.5, bar_spacing=0,
31853189 bar_spacing_abs = bar_spacing * bar_width
31863190 margin_abs = 0.5 * group_spacing * bar_width
31873191
3188- if dataset_labels is None :
3189- dataset_labels = [None ] * num_datasets
3192+ if labels is None :
3193+ labels = [None ] * num_datasets
31903194 else :
3191- assert len (dataset_labels ) == num_datasets
3195+ assert len (labels ) == num_datasets
31923196
31933197 # place the bars, but only use numerical positions, categorical tick labels
31943198 # are handled separately below
3195- for i , (hs , dataset_label , color ) in enumerate (
3196- zip (heights , dataset_labels , colors )):
3199+ for i , (hs , label , color ) in enumerate (
3200+ zip (heights , labels , colors )):
31973201 lefts = (group_centers - 0.5 * group_distance + margin_abs
31983202 + i * (bar_width + bar_spacing_abs ))
31993203 if orientation == "vertical" :
32003204 self .bar (lefts , hs , width = bar_width , align = "edge" ,
3201- label = dataset_label , color = color , ** kwargs )
3205+ label = label , color = color , ** kwargs )
32023206 else :
32033207 self .barh (lefts , hs , height = bar_width , align = "edge" ,
3204- label = dataset_label , color = color , ** kwargs )
3208+ label = label , color = color , ** kwargs )
32053209
32063210 if tick_labels is not None :
32073211 if orientation == "vertical" :
0 commit comments