直方图就是可以看数据整体分布情况
import numpy as np
import pandas as pd
from pandas import Series,DataFrame
import matplotlib.pyplot as plt
s = Series(np.random.randn(1000))
print(s)
plt.hist(s)
调整柱子宽度
plt.hist(s,rwidth=0.5)
另一个例子
#另一个例子
a = np.arange(10)
print(a)
plt.hist(a,rwidth=0.8)
re = plt.hist(s,rwidth=0.9)
print(re)
print(type(re))
print(len(re))
print('-----------')
(array([ 7., 26., 84., 202., 282., 205., 116., 58., 17., 3.]), array([-3.10819617, -2.44536828, -1.78254038, -1.11971249, -0.45688459,
0.2059433 , 0.8687712 , 1.53159909, 2.19442699, 2.85725488,
3.52008278]), <a list of 10 Patch objects>)
<class 'tuple'>
3
print(re[0])#代表出现的次数
print(re[1])#间隔
print(re[2])#list十个矩形
20个矩形
#20个矩形~
plt.hist(s,rwidth=0.9,bins=20)
plt.hist(s,rwidth=0.9,bins=20,color='r',stacked = False)#还可以变成水平的。。
#密度图kind默认为line
s.plot(kind = 'kde')#密度图