Matplotlib – PyPlot

The PyPlot is a sub module and a lot of Matplotlib functionalities reside in it. Before moving further, we’ve prepared a video tutorial to learn what is PyPlot in Matplotlib:

How to import PyPlot

Let us see who to import the pyplot submodule:

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

Example

Let us now see an example wherein we will use the Matplotlib module PyPlot and draw:

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

Pyplot Matplotlib


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:

Run first Matplotlib program
Matplotlib - Plotting
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment