31 Jan Matplotlib – PyPlot
The PyPlot is a sub module and a lot of Matplotlib functionalities reside in it, therefore import it as shown below:
1 2 3 |
import matplotlib.pyplot as plt |
The following are the methods you can use to create different plots with Matplotlib sub module PyPlot:
- bar(): For a bar plot
- hist(): Plot a Histogram
- pie(): Plot a pie chart
- scatter(): Form a scatter plot
- stem(): Form a stem plot
- step(): Form a step plot
Let us now see an example wherein we will use the Matplotlib module PyPlot and draw:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import matplotlib.pyplot as plt import numpy as np # xpts for x-coodinate # ypts for y-coordinate xpts = np.array([0, 10]) ypts = np.array([0, 125]) # Plot using the pyplot.plot() method plt.plot(xpts, ypts) # 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
No Comments