Bar chart example in python

import matplotlib.pyplot as plt
import numpy as np
 
objects = ('Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp')
y_pos = np.arange(len(objects))
performance = [10,8,6,4,2,1]
 
plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.ylabel('Usage')
plt.title('Programming language usage')
 
plt.show()
 
Explanation: In this program we are Importing(Accessing) matplotlib and numpy libraries. these libraries help in mathematical, data analysis and graphing functions. objects is having data in list form. y_pos is having object to map y points on graph based on length of list. len returns number of items in list. performance in another list used as X points on graph
 
plt.bar function is passing y point positions data, performance rating list data, align attribute having value center and transparency of bar graph in alpha. an integer between 0 and 1 specifying the transparency of each bar. A lower value of alpha results in a more transparent bar chart. xtics function takes y points data and maps objects data on those positions.
 
ylabel function names y axis label to show. title function shows the Label for bar graph. show function shows the graph on screen
 

 

 

ADV.

If you want to publish your own  website like this then email to This email address is being protected from spambots. You need JavaScript enabled to view it.

In case you are looking for Desktops under 15000 rupees, you can check below Affiliate link

Desktops under 15000 rupees