The first thing to figure out is a concept, histogram and bar chart.
The difference between a histogram and a bar chart:
Bar chart is the length of the bar to indicate how many categories of frequency, its width (indicating category) is fixed;
The histogram is the amount of the frequency of each group by area, the height of the rectangle represents the frequency of each group, and the width represents the group spacing of each group, so its height and width are meaningful.
Because of the continuity of the grouped data, the rectangles of the histogram are usually arranged consecutively, while the bar charts are arranged separately.
Bar charts are primarily used to display categorical data, while histograms are primarily used to display data-type data.
Example code:
[Python] View plain copy
#概率分布直方图
#高斯分布
#均值为0
Mean = 0
#标准差为1, the reaction data set or the scattered values
Sigma = 1
X=MEAN+SIGMA*NP.RANDOM.RANDN (10000)
Fig, (AX0,AX1) = Plt.subplots (nrows=2,figsize= (9,6))
#第二个参数是柱子宽一些还是窄一些, the bigger the narrower the more dense
Ax0.hist (x,40,normed=1,histtype= ' bar ', facecolor= ' Yellowgreen ', alpha=0.75)
# #pdf概率分布图, 10,000 a number of the numbers that grumble in a certain interval
Ax0.set_title (' PDF ')
Ax1.hist (x,20,normed=1,histtype= ' bar ', facecolor= ' Pink ', alpha=0.75,cumulative=true,rwidth=0.8)
#cdf累计概率函数, Cumulative cumulative. For example, the probability of counting a number less than 5
Ax1.set_title ("CDF")
Fig.subplots_adjust (hspace=0.4)
Plt.show ()
Python-matplotlib Picture Histogram hist