Python-matplotlib Picture Histogram hist

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.