Let’s learn together how to create bar chart in Python matplotlib library.
To create a bar chart in MatPlotlib I need data. I have a list of salesman and number of product_sold.
There is a bar function which creates a bar chart. As arguments I have salesmman as x values, product_sold for y values and more optionals. I used lightgray as color theme and brown for edge colors (ec stands for edge color).
import matplotlib.pyplot as plt products_sold = [55, 72, 63, 47, 58] salesman = ['Joe', 'Monica', 'Tom', 'Ana', 'Paul'] plt.bar(salesman, products_sold, color='lightgray',ec='brown') plt.title('Python course sales') plt.show()
This is how my bar grapg looks like. I can improve it even further using more bar function arguments.