seaborn 与 iris 数据集

Posted luyunan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了seaborn 与 iris 数据集相关的知识,希望对你有一定的参考价值。

简易用法

sns.scatterplot(x='sepal_length', y='sepal_width', data=df, hue='species', style='species')
sns.lineplot(x=np.linspace(0, 1, 10), y=np.random.rand(10))
sns.relplot(x='sepal_length', y='sepal_width', data=df, hue='species', style='species', col='species')
sns.stripplot(x='species', y='sepal_width', data=df, hue='species', size=4)
sns.swarmplot(x='species', y='sepal_width', data=df, hue='species', size=4)
sns.boxplot(x='species', y='sepal_width', data=df, hue='species')
sns.violinplot(x='species', y='sepal_width', data=df, hue='species')
sns.barplot(x='species', y='sepal_width', data=df, hue='species')
sns.distplot(df.sepal_length, bins=50, rug=True)
sns.kdeplot(df.sepal_length, df.sepal_width, shade=True, cbar=True, cmap='Reds')
sns.jointplot(df.sepal_length, df.sepal_width, kind='kde')
sns.pairplot(df, hue="species")
sns.heatmap(np.random.randn(8, 8), annot=True, annot_kws={'size':9,'weight':'bold', 'color':'w'}, fmt='.2f')
sns.clustermap(df.iloc[:, :4])

Relational plots(关系图)

scatterplot(散点图)

技术图片

sns.scatterplot(x='sepal_length', y='sepal_width', data=df, hue='species', style='species')

lineplot(线图)

sns.lineplot(x=np.linspace(0, 1, 10), y=np.random.rand(10))

relplot(关系图)

技术图片

sns.relplot(x='sepal_length', y='sepal_width', data=df, hue='species', style='species', col='species')

Categorical plots(分类图)

Categorical scatterplots(分类散点图)

stripplot(分布散点图)

技术图片

sns.stripplot(x='species', y='sepal_width', data=df, hue='species', size=4)

swarmplot(分布密度散点图)

技术图片

sns.swarmplot(x='species', y='sepal_width', data=df, hue='species', size=4)

Categorical distribution plots(分类分布图)

boxplot(箱线图)

技术图片

sns.boxplot(x='species', y='sepal_width', data=df, hue='species')

violinplot(小提琴图)

技术图片

sns.violinplot(x='species', y='sepal_width', data=df, hue='species')

Categorical estimate plots(分类估计图)

barplot(条形图)

技术图片

sns.barplot(x='species', y='sepal_width', data=df, hue='species')

Distribution plots(分布图)

distplot(直方图)

技术图片

sns.distplot(df.sepal_length, bins=50, rug=True)

kdeplot(核密度图)

技术图片

sns.kdeplot(df.sepal_length, df.sepal_width, shade=True, cbar=True, cmap='Reds')

jointplot(联合分布图)

技术图片

sns.jointplot(df.sepal_length, df.sepal_width, kind='kde')

pairplot(变量关系组图)

技术图片

sns.pairplot(df, hue="species")

Matrix plots(矩阵图)

heatmap(热力图)

技术图片

data = np.random.randn(8, 8)
sns.heatmap(data, annot=True, annot_kws={'size':9,'weight':'bold', 'color':'w'}, fmt='.2f')

clustermap(聚类图)

技术图片

sns.clustermap(df.iloc[:, :4])

以上是关于seaborn 与 iris 数据集的主要内容,如果未能解决你的问题,请参考以下文章

从Seaborn对图获取数据数组

如何自定义 seaborn.scatterplot 图例?

Seaborn 和 pd.scatter_matrix() 绘图颜色问题

使用 seaborn 在 x y 散点图中添加标签

数据可视化应用数据统计分析的显著性标注(附Python和R语言代码)

sklearn训练感知器用iris数据集