@@ -162,7 +162,7 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
162
162
163
163
loc='upper right', bbox_to_anchor=(0.5, 0.5)
164
164
165
- ncol : int, default: 1
165
+ ncols : int, default: 1
166
166
The number of columns that the legend has.
167
167
168
168
prop : None or `matplotlib.font_manager.FontProperties` or dict
@@ -294,6 +294,7 @@ class Legend(Artist):
294
294
def __str__ (self ):
295
295
return "Legend"
296
296
297
+ @_api .rename_parameter ("3.6" , "ncol" , "ncols" )
297
298
@_api .make_keyword_only ("3.6" , "loc" )
298
299
@_docstring .dedent_interpd
299
300
def __init__ (
@@ -317,7 +318,7 @@ def __init__(
317
318
borderaxespad = None , # pad between the axes and legend border
318
319
columnspacing = None , # spacing between columns
319
320
320
- ncol = 1 , # number of columns
321
+ ncols = 1 , # number of columns
321
322
mode = None , # horizontal distribution of columns: None or "expand"
322
323
323
324
fancybox = None , # True: fancy box, False: rounded box, None: rcParam
@@ -418,8 +419,8 @@ def val_or_rc(val, rc_name):
418
419
419
420
handles = list (handles )
420
421
if len (handles ) < 2 :
421
- ncol = 1
422
- self ._ncol = ncol
422
+ ncols = 1
423
+ self ._ncols = ncols
423
424
424
425
if self .numpoints <= 0 :
425
426
raise ValueError ("numpoints must be > 0; it was %d" % numpoints )
@@ -767,12 +768,12 @@ def _init_legend_box(self, handles, labels, markerfirst=True):
767
768
handles_and_labels .append ((handlebox , textbox ))
768
769
769
770
columnbox = []
770
- # array_split splits n handles_and_labels into ncol columns, with the
771
- # first n%ncol columns having an extra entry. filter(len, ...) handles
772
- # the case where n < ncol : the last ncol -n columns are empty and get
773
- # filtered out.
774
- for handles_and_labels_column \
775
- in filter ( len , np .array_split (handles_and_labels , self ._ncol )):
771
+ # array_split splits n handles_and_labels into ncols columns, with the
772
+ # first n%ncols columns having an extra entry. filter(len, ...)
773
+ # handles the case where n < ncols : the last ncols -n columns are empty
774
+ # and get filtered out.
775
+ for handles_and_labels_column in filter (
776
+ len , np .array_split (handles_and_labels , self ._ncols )):
776
777
# pack handlebox and labelbox into itembox
777
778
itemboxes = [HPacker (pad = 0 ,
778
779
sep = self .handletextpad * fontsize ,
0 commit comments