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.
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.
That’s it, you can try your own to get this beautiful bar chart using above code.