Histogram using python | Histogram tutorial | Histogram using matplotlib

Поділитися
Вставка
  • Опубліковано 21 лип 2024
  • In this tutorial video, you will learn how to plot and customize histogram using python. We will be using the matplotlib library to plot histograms.
    Thanks for watching!
    Roshan Cyriac Mathew
    Subscribe to my channel on:
    bit.ly/2Xgqx3n
    Stay updated on my Instagram page:
    / theaianddsc. .
    Histogram tutorial code:
    github.com/roshancyriacmathew...
    Some of the topics discussed in this video include:
    How to plot a histogram?
    How to change the number of bins in a histogram?
    How to set the bin ranges for a histogram?
    adding edge colour to the bars in a histogram
    changing the colour of the histogram
    adding styles to the plot
    multiple histogram / multiple data in a histogram
    adding legend in a histogram
    overlapping histogram
    step histogram
    histogram subplots
    plotting histogram from CSV file
    Matplotlib style guide:
    matplotlib.org/stable/gallery...
    #histogram #histogramusingpython #theaianddschannel

КОМЕНТАРІ • 8

  • @sahilkhan2470
    @sahilkhan2470 Рік тому +3

    Great!

  • @rajalairenmayum326
    @rajalairenmayum326 Рік тому +2

    Well explained

  • @claudiachen3557
    @claudiachen3557 Рік тому

    Great video, but I have one question which is that how do I group multiple columns together and plot them as one histogram?
    Say if I want to plot the distribution of user stats by type, but my data has the columns: January Phone call, February Phone call, January Web visit, February Web visits, and I want the histogram to see the Phone calls as one group and Web visits as another group, how could I achieve that? Thank you!

    • @TheAIandDSChannel
      @TheAIandDSChannel  Рік тому +1

      Thank you for the comment. One approach would be to extract the columns which you want to group together, which in this case is a new column that has the aggregated values of both the columns of all the phone calls and website visits. And then using this data, plot a histogram.
      phone_call_cols = ['January Phone call', 'February Phone call']
      web_visit_cols = ['January Web visit', 'February Web visit']
      df['Phone calls'] = df[phone_call_cols].sum(axis=1)
      df['Web visits'] = df[web_visit_cols].sum(axis=1)
      plt.hist([df['Phone calls'], df['Web visits']], bins=10, label=['Phone calls', 'Web visits'])
      plt.xlabel('User Stats')
      plt.ylabel('Frequency')
      plt.legend()
      plt.show()
      hope that helps.

    • @claudiachen3557
      @claudiachen3557 Рік тому

      @@TheAIandDSChannel I'll give this a try! Thank you very much!!

    • @TheAIandDSChannel
      @TheAIandDSChannel  Рік тому

      @@claudiachen3557 Your welcome!