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(散點圖)

scatterplot.png

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(關系圖)

relplot.png

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

Categorical plots(分類圖)

Categorical scatterplots(分類散點圖)

stripplot(分布散點圖)

stripplot.png

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

swarmplot(分布密度散點圖)

swarmplot.png

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

Categorical distribution plots(分類分布圖)

boxplot(箱線圖)

boxplot.png

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

violinplot(小提琴圖)

violinplot.png

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

Categorical estimate plots(分類估計圖)

barplot(條形圖)

barplot.png

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

Distribution plots(分布圖)

distplot(直方圖)

distplot.png

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

kdeplot(核密度圖)

kdeplot.png

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

jointplot(聯合分布圖)

jointplot.png

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

pairplot(變量關系組圖)

pairplot.png

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

Matrix plots(矩陣圖)

heatmap(熱力圖)

heatmap.png

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

clustermap(聚類圖)

clustermap.png

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM