失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > seaborn pairplot ax_seaborn常用的10种数据分析图表

seaborn pairplot ax_seaborn常用的10种数据分析图表

时间:2022-03-20 10:08:33

相关推荐

seaborn pairplot ax_seaborn常用的10种数据分析图表

内置示例数据集

seaborn内置了十几个示例数据集,通过load_dataset函数可以调用。

其中包括常见的泰坦尼克、鸢尾花等经典数据集。

# 查看数据集种类import seaborn as snssns.get_dataset_names()

import seaborn as sns# 导出鸢尾花数据集data = sns.load_dataset('iris')data.head()

1、散点图

函数sns.scatterplot

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inline# 小费数据集tips = sns.load_dataset('tips')ax = sns.scatterplot(x='total_bill',y='tip',data=tips)plt.show()

2、条形图

函数sns.barplot

显示数据平均值和置信区间

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inline# 小费数据集tips = sns.load_dataset("tips")ax = sns.barplot(x="day", y="total_bill", data=tips)plt.show()

3、线型图

函数sns.lineplot

绘制折线图和置信区间

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inlinefmri = sns.load_dataset("fmri")ax = sns.lineplot(x="timepoint", y="signal", data=fmri)plt.show()

4、箱线图

函数seaborn.boxplot

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inlinetips = sns.load_dataset("tips")ax = sns.boxplot(x="day", y="total_bill", data=tips)plt.show()

5、直方图

函数seaborn.distplot

import seaborn as snsimport numpy as npsns.set()import matplotlib.pyplot as plt%matplotlib inlinenp.random.seed(0)x = np.random.randn(1000)ax = sns.distplot(x)plt.show()

6、热力图

函数seaborn.heatmap

import numpy as npnp.random.seed(0)import seaborn as sns sns.set()import matplotlib.pyplot as plt%matplotlib inlineuniform_data = np.random.rand(10, 12)ax = sns.heatmap(uniform_data)plt.show()

7、散点图矩阵

函数sns.pairplot

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inlineiris = sns.load_dataset("iris")ax = sns.pairplot(iris)plt.show()

8、分类散点图

函数seaborn.catplot

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inlineexercise = sns.load_dataset("exercise")ax = sns.catplot(x="time", y="pulse", hue="kind", data=exercise)plt.show()

9、计数条形图

函数seaborn.countplot

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inlinetitanic = sns.load_dataset("titanic")ax = sns.countplot(x="class", data=titanic)plt.show()

10、回归图

函数seaborn.lmplot

绘制散点及回归图

import seaborn as snssns.set()import matplotlib.pyplot as plt%matplotlib inlinetips = sns.load_dataset("tips")ax = sns.lmplot(x="total_bill", y="tip", data=tips)plt.show()

如果觉得《seaborn pairplot ax_seaborn常用的10种数据分析图表》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。