Bar Chart in Python

Bar Chart in Python

Bar chart implementation is also very interesting using Matplotlib. In last post we discussed about Line Chart implementation in Python using Matplotlib. So for installation of Matplotlib and to start using it, you can refer Line Chart in Python page.

Now lets focus on Bar Chart Implementation. To generate bar chart using matplotlib you need to call pyplot.bar() function and need to pass minimum x and y co-ordinates values in terms of list. Lets see the example code first.

Bar Chart using Matplotlib

Apart from the basic parameter which is x and y co-ordinates value you can pass the width value, I used 0.5 to keep distance between bar charts. Next parameter we can pass is COLOR. Color can be single value like ‘red’, in this case all the bars color will be of Red color. If you want to appear your bars to be multicolor then you can pass list of colors to color parameter of bar() function. Here four color has been used, so first four will be as is and fifth onward color will get repeated. Lets see the output of above bar chart code.

Multicolor Bar Chart using Matplotlib

That’s it, you can try your own to get this beautiful bar chart using above code.

0 thoughts on “Bar Chart in Python

  • Hello ,

    I saw your tweets and thought I will check your website. Have to say it looks really nice!
    I’m also interested in this topic + have recently started my journey as young entrepreneur.

    I’m also looking for the ways on how to promote my website. I have tried AdSense and Facebok Ads, however it is getting very expensive.
    Can you recommend something what works best for you?

    Would appreciate, if you can have a quick look at my website and give me an advice what I should improve: https://janzac.com/
    (Recently I have added a new page about Rockwall Investments and the way how normal people can make money with this company.)

    I wanted to subscribe to your newsletter, but I couldn’t find it. Do you have it?

    Hope to hear from you soon.

    P.S.
    Maybe I will add link to your website on my website and you will add link to my website on your website? It will improve SEO of our websites, right? What do you think?

    Regards
    Jan Zac

    • Hello,
      Your website is really good and theme used by you is really impressive. Definitely I will add newsletter section on my website. Thank you for your valuable suggestion. Keep in touch. You can mail me on admin@pythonport.com

      With Regards,

  • In Python we can use Matplotlib to create amazing charts. Stacked bar chart is a great way to display totals while combining the group items that make up to the total.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>