Matplotlib Tutorial 5 – Histograms




[ad_1]

This matplotlib tutorial shows how to plot histograms. Histograms are used to plot frequency of a variable. In this tutorial we will do data analysis of blood sugar levels of different patients and also plot side by side bars for men and women’s blood sugar datasets using pyplot.hist method

Topics that are covered in this Video:
0:00 what is Histograms?
1:22 Plot histograms using hist() function
1:35 what is bins and buckets in histogram
2:30 rwidth parameters
3:58 API for hist() function
7:31 orientation property of Histograms

Code link: https://github.com/codebasics/py/blob/master/matpltlib/5_histogram/5_histogram.ipynb

Next Video:
Matplotlib Tutorial 6 – Pie Chart: https://www.youtube.com/watch?v=GOuUGWGUT14&list=PLeo1K3hjS3uu4Lr8_kro2AqaO6CFYgKOl&index=6

Populor Playlist:
Data Science Full Course: https://www.youtube.com/playlist?list=PLeo1K3hjS3us_ELKYSj_Fth2tIEkdKXvV

Data Science Project: https://www.youtube.com/watch?v=rdfbcdP75KI&list=PLeo1K3hjS3uu7clOTtwsp94PcHbzqpAdg

Machine learning tutorials: https://www.youtube.com/watch?v=gmvvaobm7eQ&list=PLeo1K3hjS3uvCeTYTeyfe0-rN5r8zn9rw

Pandas: https://www.youtube.com/watch?v=CmorAWRsCAw&list=PLeo1K3hjS3uuASpe-1LjfG5f14Bnozjwy

matplotlib: https://www.youtube.com/watch?v=qqwf4Vuj8oM&list=PLeo1K3hjS3uu4Lr8_kro2AqaO6CFYgKOl

Python: https://www.youtube.com/playlist?list=PLeo1K3hjS3uv5U-Lmlnucd7gqF-3ehIh0

Jupyter Notebook: https://www.youtube.com/watch?v=q_BzsPxwLOE&list=PLeo1K3hjS3uuZPwzACannnFSn9qHn8to8

Website: http://codebasicshub.com/
Facebook: https://www.facebook.com/codebasicshub
Twitter: https://twitter.com/codebasicshub

Source


[ad_2]

Comment List

  • codebasics
    November 23, 2020

    Hi, How to histogram using 2 variables on x axis using 2columns from csv file – kindly explain

  • codebasics
    November 23, 2020

    Great video. You went straight to the point. Respect.

  • codebasics
    November 23, 2020

    sir if I want to show the number of percentage how to do that
    thanks for your videos

  • codebasics
    November 23, 2020

    Hi, Please provide some insight on the below-

    Case 1 —

    When I do the below

    n, bins, patches = ax[0].hist(data, 20, alpha=0.5)

    I get count on y axis for values that are in corresponding bins on x axis.

    Case 2 —

    Then I do the below

    n, bins, patches = ax[1].hist(data, 20, density='true', alpha=0.5)

    Case 3 —

    and then plot the best fit line-

    mu, sigma = scipy.stats.norm.fit(data)

    best_fit_line = scipy.stats.norm.pdf(bins, mu, sigma)

    plt.plot(bins, best_fit_line)

    In case 2 and 3, I get probability distribution on y axis.

    I want to achieve case 2 and 3 together but I want Counts on y axis as the way they are shown in Case 1. How to do this?

  • codebasics
    November 23, 2020

    nice tutorial. love to see new series in the next time

  • codebasics
    November 23, 2020

    Exactly what i was looking for!

  • codebasics
    November 23, 2020

    Awesome

  • codebasics
    November 23, 2020

    very nice explaination thanks

  • codebasics
    November 23, 2020

    But your data was different and histogram is different

  • codebasics
    November 23, 2020

    I don't know why everytime I plot xlabel and ylabel it always show error as not callable..Pls help

  • codebasics
    November 23, 2020

    what about women who have sugar in the range 80-90?

  • codebasics
    November 23, 2020

    Thank you so much. Excellent tutorial.

  • codebasics
    November 23, 2020

    What is the use of legend here
    Pls reply

  • codebasics
    November 23, 2020

    Thanks for video, this is so useful. And beautiful accent…

  • codebasics
    November 23, 2020

    Thanks bro.

  • codebasics
    November 23, 2020

    Thanks a lot

  • codebasics
    November 23, 2020

    what is meant by bins? how do we select number of bins?

  • codebasics
    November 23, 2020

    how can you graph on python lets say we have there are 160 people with the same blood sugar and you don't want to write it down 160 times…?

  • codebasics
    November 23, 2020

    explanation is good

  • codebasics
    November 23, 2020

    video is not clear

  • codebasics
    November 23, 2020

    sir where to use these matplotlib, how to know for the data to use which chart

  • codebasics
    November 23, 2020

    excellent tutorial!

  • codebasics
    November 23, 2020

    can We have green and yellow in Same bar ? mean we can do Men is dark green and women is light yellow ?

  • codebasics
    November 23, 2020

    This is confusing because though both sets share a range (say 80-100) the illustrations suggests that one set has values between 80 and 90 and the other set has values between 90 and 100. What would be useful is if the x axis is relabelled according to range e.g. 80-100 and both bars for each data set share that range. Can you remedy? …

  • codebasics
    November 23, 2020

    excellent

  • codebasics
    November 23, 2020

    Very good

  • codebasics
    November 23, 2020

    "Python is where it's at! You can do almost anything with it."

Write a comment