forked from Techiral/A-Z-Python-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarGraph.py
More file actions
32 lines (31 loc) · 862 Bytes
/
BarGraph.py
File metadata and controls
32 lines (31 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import matplotlib.pyplot as plt
companies = ['Google', 'Amazon', 'Microsoft', 'FB']
revenues = [100, 110, 80, 145]
profits = [15, 20, 10, 30]
xpos = [0, 1, 2, 3]
firstx = []
secondx = []
for i in range(len(xpos)):
firstx.append(xpos[i]-0.2)
secondx.append(xpos[i]+0.2)
plt.bar(xpos, revenues, label='Revenue')
plt.ylabel('Revenue')
plt.xticks(xpos, companies)
plt.legend()
plt.show()
import matplotlib.pyplot as plt
companies = ['Google', 'Amazon', 'Microsoft', 'FB']
revenues = [100, 110, 80, 145]
profits = [15, 20, 10, 30]
xpos = [0, 1, 2, 3]
firstx = []
secondx = []
for i in range(len(xpos)):
firstx.append(xpos[i]-0.2)
secondx.append(xpos[i]+0.2)
plt.bar(firstx, revenues, width=0.4, label='Revenue')
plt.bar(secondx, profits, width=0.4, label='Profits')
plt.title('Revenues & Profits')
plt.xticks(xpos, companies)
plt.legend()
plt.show()