14 Feb Matplotlib – Bar Graph
To plot a bar graph in Matplotlib, use the bar() method. Before moving further, we’ve prepared a video tutorial to plot a Bar Graph in Matplotlib:
Example
Let us see an example wherein we will plot a bar graph for student and student marks:
import matplotlib.pyplot as plt
import numpy as np
# x and y coordinates
student = np.array(["Tim", "John", "Amit", "Jacob", "Karl", "Gary"])
marks = np.array([85, 59, 99, 77, 67, 95 ])
# Plot a bar graph using the pyplot.bar() method
# The x and y coordinates below are the student and marks respectively
plt.bar(student, marks)
# The labels for x-coordinate and y-coordinate
plt.xlabel("Student")
plt.ylabel("Marks")
# Display the figure
plt.show()
Output

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
No Comments