[Python] Código de dibujo del histograma

#绘制直方图
def drawHist(heights):
    #创建直方图
    #第一个参数为待绘制的定量数据,不同于定性数据,这里并没有事先进行频数统计
    #第二个参数为划分的区间个数
    bins = np.arange(0, 1.01, 0.01)
    n, bins, patches = pyplot.hist(heights, bins)
    pyplot.xlabel('x轴')
    pyplot.ylabel('y轴')
    pyplot.title('标题')
    pyplot.show()
    return n, bins, patches

a = np.array([1,2,3])
n, bins, patches = drawHist(a)

Supongo que te gusta

Origin blog.csdn.net/weixin_38705903/article/details/106571702
Recomendado
Clasificación