I want to plot a seaborn regplot. my code:
x=data['Healthy life expectancy']
y=data['max_dead']
sns.regplot(x,y)
plt.show()
However this gives me future warning error. How to fix this warning?
FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid
positional argument will be 'data', and passing other arguments without an explicit keyword will
result in an error or misinterpretation.
Seaborn 0.12
seaborn 0.12, theFutureWarningfromseaborn 0.11is now anTypeError.datamay be specified as the first positional argument for seaborn plots. All other arguments must use keywords (e.g.x=andy=). This applies to allseabornplotting functions.sns.*plot(data=penguins, x="bill_length_mm", y="bill_depth_mm")orsns.*plot(penguins, x="bill_length_mm", y="bill_depth_mm")sns.*plot(data=penguins.bill_length_mm)orsns.*plot(penguins.bill_length_mm)TypeError: *plot() takes from 0 to 1 positional arguments but 3 were givenoccurs when no keywords are passed.sns.*plot(penguins, "bill_length_mm", "bill_depth_mm")TypeError: *plot() got multiple values for argument 'data'occurs whendata=is used after passingxandyas positional arguments.sns.*plot("bill_length_mm", "bill_depth_mm", data=penguins)TypeError: *plot() takes from 0 to 1 positional arguments but 2 positional arguments (and 1 keyword-only argument) were givenoccurs when positional arguments are passed forxandy, followed by a keyword argument other thandatasns.*plot(penguins.bill_length_mm, penguins.bill_depth_mm, kind="reg")pythonexplanation.Seaborn 0.11
xandyparameters forseaborn.regplot, or any of the other seaborn plot functions with this warning.sns.regplot(x=x, y=y), wherexandyare parameters forregplot, to which you are passingxandyvariables.data, will result in anerrorormisinterpretation.xandyare used as the data variable names because that is what is used in the OP. Data can be assigned to any variable name (e.g.aandb).FutureWarning: Pass the following variable as a keyword arg: x, which can be generated by plots only requiringxory, such as:sns.countplot(penguins['sex']), but should besns.countplot(x=penguins['sex'])orsns.countplot(y=penguins['sex'])Ignore the warnings
data, and passing other arguments without an explicit keyword will result in an error or misinterpretation.