Matplotlib Tutorial 3 bar charts and histograms




[ad_1]

The plt.bar creates the bar chart for us. If you do not explicitly choose a color, then, despite doing multiple plots, all bars will look the same. This gives us a change to cover a new Matplotlib customization option, however. You can use color to color just about any kind of plot, using colors like g for green, b for blue, r for red, and so on. You can also use hex color codes, like #191970

Next, we can cover histograms. Very much like a bar chart, histograms tend to show distribution by grouping segments together. Examples of this might be age groups, or scores on a test. Rather than showing every single age a group might be, maybe you just show people from 20-25, 25-30… and so on.

sample code: http://pythonprogramming.net
http://hkinsley.com
https://twitter.com/sentdex
http://sentdex.com
http://seaofbtc.com

Source


[ad_2]

Comment List

  • sentdex
    December 31, 2020

    actually you are rite no one in the schools right now

  • sentdex
    December 31, 2020

    how to plot histogram with 2 variables in axis and 1 variable in y axis from csv file – kindly help

  • sentdex
    December 31, 2020

    How bar plot calculating intervals on x_axis and y_axis

  • sentdex
    December 31, 2020

    Hello dear… you are one of great teacher…I request you to please make video of matplotlib with bigdata file.
    I am trying to apply these concepts on my data but I am facing issues as duplicate value are there.. like BH name repeating and I have to use pivot table but not able to use these concepts on pivot table

  • sentdex
    December 31, 2020

    plt.bar("population_age","ids" )

    ^

    SyntaxError: invalid syntax

    wtf man

  • sentdex
    December 31, 2020

    Hi, awesome tutorial just had a question. What if my x-axis for both the data sets is the same (for eg 2,4,6,8) It plots the greater value not showing the smaller value. How to plot them both as if they are stacked or any other way you can tell?

  • sentdex
    December 31, 2020

    great videos, absolutely love your teaching style

  • sentdex
    December 31, 2020

    Hey. While executing this, can not see legend box. It shows "No handles with labels found to put in legend." Can you explain this?

  • sentdex
    December 31, 2020

    11:43 Little did he know

  • sentdex
    December 31, 2020

    This is the best channel ever where I cannot feel bored and teaching is super and we get full information

  • sentdex
    December 31, 2020

    Nice vid. Very helpful. But how can you put labels at the top of bar chart?

  • sentdex
    December 31, 2020

    Great videos, although a bin in Britain actually refers to a 'trash can.'

  • sentdex
    December 31, 2020

    please do it by using dataframe that is the reality? what we do.

  • sentdex
    December 31, 2020

    no one in schools. They all are at home watching your tutorials.

  • sentdex
    December 31, 2020

    thanks

  • sentdex
    December 31, 2020

    If we do for some random numbers, it is fun:
    code below:
    x=np.array(np.random.randint(1,10,5))

    y=np.array(np.random.randint(10,100,5))

    plt.bar(x,y,label='bar1')

    x1=np.array(np.random.randint(1,10,5))

    y1=np.array(np.random.randint(10,100,5))

    plt.bar(x1,y1,label='Bar2')

    plt.title('Some random graphncheck it out')

    plt.xlabel('some random values on x axis')

    plt.ylabel('some random values on y axis')

    plt.legend()

    plt.show()

  • sentdex
    December 31, 2020

    my y bar, the vertical one, doesn't have a number. I'm using matplotlib 3.6.8.

  • sentdex
    December 31, 2020

    Great video. One query: how can we draw frequency polygons using matplotlib ?

  • sentdex
    December 31, 2020

    Great video, it's much more explicit than other videos I saw before.

  • sentdex
    December 31, 2020

    thanks man..easily understandable videos

  • sentdex
    December 31, 2020

    Can you show me how use dataframe of Python. Thank you very much!

  • sentdex
    December 31, 2020

    Yo thank u so much I had to make 80 histograms for work

  • sentdex
    December 31, 2020

    Excellent tutorial, really helped me out.

    On a side note, has anyone ever told you you sound like another YouTuber called Datto?

  • sentdex
    December 31, 2020

    An histogram is a subset of bar graphs.

  • sentdex
    December 31, 2020

    fantastic

  • sentdex
    December 31, 2020

    can u please elaborate what does "ids " gives mathematically

  • sentdex
    December 31, 2020

    Awesome Video! I've had to learn Matlab over the past year and a half due to the curriculum for the Computer Engineering program I'm a part of. As a student, I have access freely, but that ends once I graduate. Thanks for presenting an alternative to Matlab for those of us with a limited budget!

  • sentdex
    December 31, 2020

    thank you

Write a comment