@@ -513,14 +513,23 @@ def _plot_args(self, axes, tup, kwargs, *,
513513
514514 label = kwargs .get ('label' )
515515 n_datasets = max (ncx , ncy )
516- if n_datasets > 1 and not cbook .is_scalar_or_string (label ):
516+
517+ if cbook .is_scalar_or_string (label ):
518+ labels = [label ] * n_datasets
519+ else :
517520 if len (label ) != n_datasets :
518- raise ValueError (f"label must be scalar or have the same "
519- f"length as the input data, but found "
520- f"{ len (label )} for { n_datasets } datasets." )
521+ if n_datasets > 1 :
522+ raise ValueError (f"label must be scalar or have the same "
523+ f"length as the input data, but found "
524+ f"{ len (label )} for { n_datasets } datasets." )
525+ else :
526+ msg = (f'Passing label as a length { len (label )} sequence when '
527+ 'plotting a single dataset is deprecated in Matplotlib 3.9 '
528+ 'and will error in 3.11. To keep the current behavior, '
529+ 'cast the sequence to string before passing.' )
530+ _api .warn_deprecated ('3.9' , message = msg )
531+ label = [label ]
521532 labels = label
522- else :
523- labels = [label ] * n_datasets
524533
525534 result = (make_artist (axes , x [:, j % ncx ], y [:, j % ncy ], kw ,
526535 {** kwargs , 'label' : label })
0 commit comments