barplot python bar values code example
Example 1: how to plot a bar using matplotlib
import matplotlib.pyplot as plt
data = {'C':20, 'C++':15, 'Java':30,
'Python':35}
courses = list(data.keys())
values = list(data.values())
fig = plt.figure(figsize = (5, 5))
plt.bar(courses, values, color ='green',
width = 0.4)
plt.xlabel("Courses offered")
plt.ylabel("No. of students enrolled")
plt.title("Students enrolled in different courses")
plt.show()
Example 2: how to increase bar width in python matplogtlib
plt.bar(x, y, width=30)