import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pandas import Series, DataFrame
%matplotlib inline
# 引入
import seaborn as sns
/Users/bennyrhys/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
return f(*args, **kwds)
/Users/bennyrhys/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
return f(*args, **kwds)
/Users/bennyrhys/opt/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
return f(*args, **kwds)
# 正态分布生成1000个数据
s1 = Series(np.random.randn(1000))
# 直方图
plt.hist(s1)
(array([ 1., 34., 105., 253., 330., 198., 68., 10., 0., 1.]),
array([-3.48152703, -2.68232526, -1.88312349, -1.08392171, -0.28471994,
0.51448183, 1.31368361, 2.11288538, 2.91208715, 3.71128892,
4.5104907 ]),
<a list of 10 Patch objects>)
# 密度图 Series 的方法直接画.plot
s1.plot(kind='kde')
<matplotlib.axes._subplots.AxesSubplot at 0x1a1e906a90>
# 直方图,密度图.distplot()
# 参数 数据,分块,是否直方图,是否密度图,rug分布情况
sns.distplot(s1, bins=20, hist=True, kde=True, rug=True)
<matplotlib.axes._subplots.AxesSubplot at 0x1a1faf2410>
# 密度图
# 参数 数据,颜色填充, 颜色
sns.kdeplot(s1, shade=True, color='r')
<matplotlib.axes._subplots.AxesSubplot at 0x1a2258d850>
sns.rugplot(s1)
<matplotlib.axes._subplots.AxesSubplot at 0x1a227783d0>
plt.plot(s1)
[<matplotlib.lines.Line2D at 0x1a225d6650>]
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有