-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarChart3.py
More file actions
25 lines (22 loc) · 912 Bytes
/
Copy pathBarChart3.py
File metadata and controls
25 lines (22 loc) · 912 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
#Write a Python programming to display a bar chart of the popularity of programming Languages.
# Select the width of each bar and their positions.
import matplotlib.pyplot as plt
x = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']
popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]
x_pos = [i for i, _ in enumerate(x)]
plt.xlabel("Languages")
plt.ylabel("Popularity")
plt.title("PopularitY of Programming Language\n" + "Worldwide, Oct 2017 compared to a year ago")
plt.xticks(x_pos, x)
# Select the width of each bar and their positions
width = [0.1,0.2,0.5,1.1,0.2,0.3]
y_pos = [0,.8,1.5,3,5,6]
# Create bars
plt.bar(y_pos, popularity, width=width)
plt.xticks(y_pos, x)
# Turn on the grid
plt.minorticks_on()
plt.grid(which='major', linestyle='-', linewidth='0.5', color='red')
# Customize the minor grid
plt.grid(which='minor', linestyle=':', linewidth='0.5', color='black')
plt.show()