Welcome folks today in this blog post we will be plotting a line graph
in python using matplotlib
library. All the full source code of the application is shown below.
Get Started
In order to get started you need to install the following matplotlib
library using the pip
command as shown below
pip install matplotlib
After installing this library you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from matplotlib import pyplot as plt # x-axis values x = [5, 2, 9, 4, 7] # Y-axis values y = [10, 5, 8, 4, 2] # Function to plot plt.plot(x,y) # function to show the plot plt.show() |
And now if you execute the above python script by typing the below command as shown below
python app.py