如何用Seaborn描绘线图,分面网格关联图,密度图,连接图,热力图,线性回归图,分面网格绘图
生活随笔
收集整理的這篇文章主要介紹了
如何用Seaborn描绘线图,分面网格关联图,密度图,连接图,热力图,线性回归图,分面网格绘图
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
事前準備請看之前的文章0o0!
線圖
data = {'apple':[4,0,7,8],'orange':[3,5,6,7],'bananas':[6,4,5,3] } df = pd.DataFrame(data,index=['a','b','c','d']) df plt.figure(dpi=150) sns.lineplot(data=df)#一列一條線導入數據
tips = sns.load_dataset("tips") tips.head() plt.figure(dpi=150) sns.lineplot(x= 'total_bill',y='tip',data=tips) sns.lineplot(x = 'total_bill',y='tip',hue='sex',data=tips) plt.figure(dpi=150) sns.lineplot(x = 'total_bill',y='tip',hue='sex',size='smoker',style='time',data=tips) mpg_df = sns.load_dataset("mpg") mpg_df g = sns.relplot(x="displacement",y="mpg",data=mpg_df)#默認散點圖 g = sns.relplot(x="displacement",y="mpg",col="cylinders",data=mpg_df) g = sns.relplot(x="displacement",y="mpg",col="cylinders",row="origin",data=mpg_df)-
col_wrap=3 一行三個
密度圖(雙變量)
n=1024 x = np.random.normal(0,1,n) y = np.random.normal(0,1,n) g = sns.kdeplot(x,y) g = sns.kdeplot(x,y,shade=True)連接圖
n=1024 x = np.random.normal(0,1,n) y = np.random.normal(0,1,n) g = sns.jointplot(x,y) g = sns.jointplot(x,y,kind="reg") g = sns.jointplot(x,y,kind="kde") g = sns.jointplot(x,y,kind="hex")熱力圖
df = pd.DataFrame(np.random.rand(10,10),columns=list('abcdefghij')) df sns.heatmap(df)-
可以改變顏色
線性回歸圖
sns.regplot(x='total_bill',y = 'tip',data=tips)分面網格線性回歸圖
sns.lmplot(x='total_bill',y = 'tip',hue='sex',data=tips,col='size',col_wrap=3)分面網格繪制
g = sns.FacetGrid(mpg_df,col="origin") g.map(sns.distplot,"mpg") g = sns.FacetGrid(mpg_df,col="origin") g.map(sns.kdeplot,"mpg")總結
以上是生活随笔為你收集整理的如何用Seaborn描绘线图,分面网格关联图,密度图,连接图,热力图,线性回归图,分面网格绘图的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么通过u盘启动进去主菜单 U盘如何进入
- 下一篇: u盘东西怎么不显示怎么办 插上U盘却无反