matplotlib可以被認(rèn)為是Python中的核心基礎(chǔ)繪圖工具,seaborn為matplotlib提供更高級(jí)別的統(tǒng)計(jì)圖形接口。
- 直方圖
hist = sns.distplot(tips['total_bill'])
hist.set_title('Total Bill Histogram with Density Plot')

圖片.png
默認(rèn)distplot將繪制直方圖和密度圖(使用核密度估計(jì))。如果我們只想要直方圖,我們可以將kde參數(shù)設(shè)置為False。
hist = sns.distplot(tips['total_bill'], kde=False)
hist.set_title('Total Bill Histogram')
hist.set_xlabel('Total Bill')
hist.set_ylabel('Frequency')

圖片.png
- 單獨(dú)輸出密度圖
hist = sns.distplot(tips['total_bill'], kde=False)
hist.set_title('Total Bill Histogram')
hist.set_xlabel('Total Bill')
hist.set_ylabel('Frequency')

圖片.png
- 地毯圖
hist_den_rug = sns.distplot(tips['total_bill'], rug=True)
hist_den_rug.set_title('Total Bill Histogram with Density and Rug Plot')
hist_den_rug.set_xlabel('Total Bill')

圖片.png
- 條形圖
count = sns.countplot('day', data=tips)
count.set_title('Count of days')
count.set_xlabel('Day of the Week')
count.set_ylabel('Frequency')

圖片.png
- 散點(diǎn)圖
scatter = sns.regplot(x='total_bill', y='tip', data=tips)
scatter.set_title('Scatterplot of Total Bill and Tip')
scatter.set_xlabel('Total Bill')
scatter.set_ylabel('Tip')

圖片.png