Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

matplotlib bar chart

import numpy as np
import matplotlib.pyplot as plt
 
  
# creating the dataset
data = {'C':20, 'C++':15, 'Java':30,
        'Python':35}
courses = list(data.keys())
values = list(data.values())
  
fig = plt.figure(figsize = (10, 5))
 
# creating the bar plot
# the format of the bar() method is: 
# plt.bar(x_value, y_value, color, width_of_bars_inches)
plt.bar(courses, values, color ='maroon',
        width = 0.4)
# x-axis label
plt.xlabel("Courses offered")
# y-axis label
plt.ylabel("No. of students enrolled")
# Title of the figure
plt.title("Students enrolled in different courses")
plt.show()
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #matplotlib #bar #chart
ADD COMMENT
Topic
Name
9+9 =