I have function that I wish to show on a plot, but it does not appear. Where did i go wrong?
(slutt means end in norwegian)
import matplotlib.pyplot as plt
xstart = 1
xslutt = 5
ystart = 7
delta_x = 1
delta_y = 3
x = xstart
y = ystart
while x <= xslutt:
plt.plot(x, y)
print(x, y)
x = x delta_x
y= y delta_y
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('My first graph!')
plt.show()
CodePudding user response:
You may pass 1d arrays to plot
, store the values in arrays then plot the line
xx, yy = [], []
while x <= xslutt:
xx.append(x)
yy.append(y)
x = delta_x
y = delta_y