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