绘制散点图以及回归线(python,matplotlib, seaborn)

#object: 绘制带回归直线的散点图
#writer: mike
#time:2020.11,1

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

data = pd.read_csv("C:\\Users\\mike1\\Desktop\\data\\zhanglijia\\dataExperiment2.csv",header=None,sep=',',names=["x","y",'z'])
#print(data.iloc[:10,:])                          #注意pandas的切片不同于R,不同于numpy
data = data.iloc[0:30,:]                          #data.iloc[30,:]会认为是第30行
print(data)

sns.regplot(x='x',y='y',data=data)     #注意data[1]这指的是行,data.ioc[10]这指的也是行,不同于R

plt.title("regressionAndPlot")
plt.show()

 

 

posted @ 2020-11-02 00:02  看星星的派大星  阅读(6313)  评论(0编辑  收藏  举报