You do not have to do anything special to pass **kwds
(see this SO question to understand the **
notation better).
All arguments that are not positional arguments of the DataFrame.plot method will be passed to the pyplot.plt method automatically.
Note: kwds
stands for keyword arguments, so you have to use arg_name = arg_value
.
You might have already used it without knowing, for example in df.plot(alpha=0.5)
: alpha is not a positional argument of DataFrame.plot
, so it is passed to pyplot.plt
.
You can see it when trying aalpha
: the error stack points to matplotlib, not pandas.
--
Note: the label
argument does not work as is.
In the pandas code, you can see that the legend labels are automatically generated from the column names, except when the y
argument is explicitly passed. It makes sense, as y
can only be a single column, where DataFrame.plot
allows you to plot all the columns at once. But label
does not accept a list of values, so there is no way to know which label to update.
It means that you have three options. Either pass a single column name as y
: in that case label
will work as intended. Or update the legend afterward (see the legend guide for reference). Or use the single-column DataFrame as a Series.
--
Edit about the original question: the **kwds
arguments are passed to pyplot.plt
, that has no direct link to the legend. So it is not possible to update the legend properties with DataFrame.plot
.