How to plot a histogram using Matplotlib in Python with a list of data?

前端 未结 5 770
醉梦人生
醉梦人生 2020-12-04 09:06

I am trying to plot a histogram using the matplotlib.hist() function but I am not sure how to do it.

I have a list

probability = [0.360         


        
5条回答
  •  一生所求
    2020-12-04 09:16

    If you haven't installed matplotlib yet just try the command.

    > pip install matplotlib
    

    Library import

    import matplotlib.pyplot as plot
    

    The histogram data:

    plot.hist(weightList,density=1, bins=20) 
    plot.axis([50, 110, 0, 0.06]) 
    #axis([xmin,xmax,ymin,ymax])
    plot.xlabel('Weight')
    plot.ylabel('Probability')
    

    Display histogram

    plot.show()
    

    And the output is like :

提交回复
热议问题