1、Seaborn介绍
Seaborn
是基于
matplotlib
的图形可视化
python
包。它提供了一种高度交互式界面,便于用户能够做出 各种有吸引力的统计图表。
Seaborn
是在
matplotlib
的基础上进行了更高级的
API
封装,从而使得作图更加容易,在大多数情况下使 用seaborn
能做出很具有吸引力的图,而使用
matplotlib
就能制作具有更多特色的图。应该把
Seaborn
视 为matplotlib
的补充,而不是替代物。
2、安装
pip install seaborn -i https://pypi.tuna.tsinghua.edu.cn/simple
3、快速上手
3.1、样式设置
stlyle
设置,修改主题风格,属性如下:
import
seaborn
as
sns
sns
.
set
(
style
=
'darkgrid'
,
context
=
'talk'
,
font
=
'STKaiti'
)
context
效果
paper
越来越大越来越粗
notebook
(默认) 越来越大越来越粗
talk
越来越大越来越粗
poster
越来越大越来越粗
context
设置,修改大小,属性如下:
3.2、线形图
4、各种图形绘制
import
seaborn
as
sns
import
matplotlib
.
pyplot
as
plt
import
pandas
as
pd
import
numpy
as
np
sns
.
set
(
style
=
'dark'
,
context
=
'poster'
,
font
=
'STKaiti'
)
#
设置样式
plt
.
figure
(
figsize
=(
9
,
6
))
x
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
20
)
y
=
np
.
sin
(
x
)
sns
.
lineplot