0% found this document useful (0 votes)
23 views

Matplot Handson

This Python code defines a function to create a simple scatter plot showing the relationship between time and distance covered. It initializes a figure and axis, sets the title, labels, and axis limits, plots the points with a label, displays the plot, and saves it as an image file. The function runs to generate and save the first plot.

Uploaded by

TECHer YT
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Matplot Handson

This Python code defines a function to create a simple scatter plot showing the relationship between time and distance covered. It initializes a figure and axis, sets the title, labels, and axis limits, plots the points with a label, displays the plot, and saves it as an image file. The function runs to generate and save the first plot.

Uploaded by

TECHer YT
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

Create your First Plot:

def test_my_first_plot():
fig=plt.figure(figsize=(8,6))
ax=fig.add_subplot(111)
t=[5,10,15,20,25]
d=[25,50,75,100,125]
ax.set(title='Time vs Distance Covered',xlabel='time (seconds)',ylabel= "distance
(meters)",xlim=(0,30),ylim=(0,130))
ax.legend()
plt.plot(t,d,label='d=5t')
plt.show()
plt.savefig('scatter.png')
test_my_first_plot()

You might also like