Seaborn 是一个 Python 数据可视化库,基于 Matplotlib 构建。它提供了大量用于绘制统计图表的函数,可以帮助用户更直观地分析和展示数据。

安装

pip install seaborn

基本使用

Seaborn 提供了多种图表类型,以下是一些常用的:

点图

import seaborn as sns
import matplotlib.pyplot as plt

# 创建散点图
sns.scatterplot(x='a', y='b', hue='c', data=df)
plt.show()

散点图示例

直方图

# 创建直方图
sns.histplot(x='a', data=df)
plt.show()

直方图示例

箱线图

# 创建箱线图
sns.boxplot(x='a', y='b', data=df)
plt.show()

箱线图示例

主题

Seaborn 还提供了多种主题,可以改变图表的样式。

sns.set_theme(style="whitegrid")

主题示例

扩展阅读

更多关于 Seaborn 的信息和示例,请访问 Seaborn 官方文档