che*_*rry 8 python plot seaborn
我想绘制一个seaborn regplot。我的代码:
x=data['Healthy life expectancy']
y=data['max_dead']
sns.regplot(x,y)
plt.show()
Run Code Online (Sandbox Code Playgroud)
然而,这给了我未来的警告错误。如何修复此警告?
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.
Run Code Online (Sandbox Code Playgroud)
Tre*_*ney 17
x和y参数seaborn.regplot。sns.regplot(x=x, y=y), wherex和y是regplot, 传递给的参数x和y变量。data,将导致error或misinterpretation。x并y用作数据变量名称,因为这是 OP 中使用的名称。数据可以分配给任何变量名(例如a和b)。import seaborn as sns
import pandas as pd
pen = sns.load_dataset('penguins')
x = pen.culmen_depth_mm
y = pen.culmen_length_mm
# plot without specifying the x, y parameters
sns.regplot(x, y)
Run Code Online (Sandbox Code Playgroud)
# plot with specifying the x, y parameters
sns.regplot(x=x, y=y)
Run Code Online (Sandbox Code Playgroud)
data,并且在没有显式关键字的情况下传递其他参数将导致错误或误解。import warnings
warnings.simplefilter(action="ignore", category=FutureWarning)
# plot without specifying the x, y parameters
sns.regplot(x, y)
Run Code Online (Sandbox Code Playgroud)