So Im supposed to plot graphs. Make a function plot_line(p1,p2) that takes two points as input arguments and plots the line between them. The two input arguments should be lists or tuples specifying x- and y-coordinates, i.e., p1 =(x1,y1)
I tried with this but my graph is just empty in the plot table. Nothing comes up
import matplotlib.pyplot as plt
print('this code will plot two points in a graph and make a line')
x1 = (float(input('enter first x value: ')))
y1 = (float(input('enter first y value: ')))
x2 = (float(input('enter second x value: ')))
y2 = (float(input('enter second y value: ')))
def plotline(p1,p2):
p1=[x1,y1]
p2=[x2,y2]
return p1,p2
x=plotline(x1,x2)
y=plotline(x1,x2)
plt.plot(x,y, label='x,y')
plt.xlabel('x')
plt.ylabel('y')
plt.legend()
plt.axis([-10,10,-10,10])
plt.title('two lines')
plt.show()
