Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
Can anyone tell me how to plot the graph in Python?

1 Answer

0 votes
by (108k points)

For plotting any graph in Python, you need to first import the Matplotlib package, and the following code will help you to create a simple line graph:

# importing the required module 

import matplotlib.pyplot as plt 

x = [9,8,0] # x axis values 

y = [5,8,3] # corresponding y axis values

plt.plot(x, y) # plotting the points

plt.xlabel('x - axis') # naming the x axis 

plt.ylabel('y - axis') # naming the y axis  

plt.title('My first graph!') # giving a title to the graph 

plt.sHow() # function to sHow the plot

The graph created will look like this:

If you are looking for an online course to learn Python, I recommend this Python Training program by Intellipaat.

Browse Categories

...