Seaborn的axes_style()函數(shù)用于設(shè)置繪圖圖表的風格樣式。使用該函數(shù)可以設(shè)置圖表的背景顏色、網(wǎng)格樣式、坐標軸樣式等。
import seaborn as sns
# 設(shè)置風格樣式為白色網(wǎng)格
sns.set_style("whitegrid")
# 繪制圖表
sns.scatterplot(x="sepal_length", y="sepal_width", data=iris)
你也可以通過傳遞參數(shù)來定制風格樣式,例如:
# 設(shè)置風格樣式為白色背景
sns.set_style("white")
# 設(shè)置背景顏色和網(wǎng)格樣式
sns.set_style("dark", {"grid.color": "red", "axes.facecolor": "yellow"})
# 繪制圖表
sns.scatterplot(x="sepal_length", y="sepal_width", data=iris)
通過使用axes_style()函數(shù),可以輕松地定制圖表的風格樣式,使圖表更加美觀和易讀。