Python Matplotlib Plotting Histogram

This is our sixth article in Python Matplotlib, in this article we are going to learn about Matplotlib Plotting Histogram, a histogram is an approximate representation of the distribution of numerical or categorical data. It was first introduced by Karl Pearson. in fact, a Histogram is just a specific kind of bar chart. we could easily use Maplotlib’s bar chart function and do some statistics to generate Histograms. However, histograms are so useful that matplotlib provides a function just for them.

 

 

 

Matplotlib Tutorials For Beginners

1: Matplotlib Introduction & Installation 

2: Matplotlib Plotting Multiple Curves

3: Matplotlib Plotting Scatter (Points)

4: Matplotlib Plotting BarChart

5: Matplotlib Plotting PieChart

 

 

 

OK now let’s create our example, the following code draws 500 values from a normal distribution and then generates histograms with 10 bins.

 

So in the above code the plt.hist() function takes a list of values as input, the range of the values will be divided

int to equal-sized bins. The plt.hist() function will generate a bar chart, one bar for one bin. The number of bins is determined by the optional parameter bins. By setting the optional parameter normed to True, the bar height is normalized and the sum of all bar heights is equal to 1.

 

 

 

So now if you run the complete code this will be the result

Python Matplotlib Plotting Histogram
Python Matplotlib Plotting Histogram

 

 

Subscribe and Get Free Video Courses & Articles in your Email

 

Share via
Copy link
Powered by Social Snap
×