练习:绘制均匀分布
#coding:utf-8
#/usr/bin/python
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
if __name__ == '__main__':
mpl.rcParams['font.sans-serif'] = [u'SimHei']
mpl.rcParams['axes.unicode_minus'] = False # win正常显示中文设置
x = np.random.rand(10000) #取10000个0-1的随机数
plt.hist(x, 30, color='B', alpha=0.5, label=u'均匀分布')#直方图,将数据等分30份
plt.legend(loc='upper left')
plt.grid()
plt.show()