python绘制直方图,观察close数据分布
绘制直方图,观察002045,2017年所有close数据分布
代码如下:
import numpy as np import pandas as pd import matplotlib.pyplot as plt import tushare as ts data = ts.get_h_data('002045',start='2017-01-01',end='2017-11-17') data = data.sort_index(axis=0, ascending=True) a = data.close plt.hist(a,30,normed=0,histtype='stepfilled',facecolor='b',alpha=0.75) plt.title('close') plt.show()
result如下: