matplotlib.pyplot is a collection of functions that make matplotlib work like MATLAB. Each pyplot the function makes some change to a figure.
e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc.
A simple program using matplotlib.pyplot
import matplotlib.pyplot as plt
plt.plot([1, 3, 8, 4])
plt.ylabel('some numbers')
plt.show()
Output:-
How to print bar graph - bar()
import matplotlib.pyplot as plt
plt.bar([1, 2,3, 4],[1,4,5,2])
plt.ylabel('some numbers')
plt.xlabel('numbers')
plt.title('Bar Graph')
plt.show()
import matplotlib.pyplot as plt
mylabel=['Apple','Banana','Orange','Mango']
plt.pie([1, 2,3, 4],labels=mylabel)
plt.title('Bar Graph')
plt.show()
Output:-
2 Comments
thankyou
ReplyDeleteit is very useful for beginners
ReplyDelete