Issue
How can one join the points with lines in the following code?
import matplotlib.pyplot as plt
for i in range(1, 10):
y = i**2
plt.plot(i, y, '-o')
plt.show
Using plt.scatter
or plt.scatter/plt.plot/plt.show
don't work either.
Solution
The code would not plot properly since plt.plot and plt.show() is looping. You might want to store your update i & y values in a list before you plot it.
import matplotlib.pyplot as plt
x = []
y = []
for i in range(1, 10):
x.append(i)
y.append(i**2)
plt.plot(x,y)
plt.show()
Answered By - Kodealine
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.