1

The matplotlib.pyplot.plot documentation says that- plot(y) # plot y using x as index array 0..N-1

So what would be the output with y=[1,2,3,4,5,6,7,8,9,10] ans with y=[2,4,6,8,10]? I plotted them but was not able to infer anything. Please Help

1 Answer 1

5

You can assume that plt.plot(y) is equivalent to plt.plot(range(len(y)), y). Meaning, the first entry in y is plotted at x=0, the second at x=1, etc until the last, at x=N-1 (where N=len(y)).

This means in the case y=[1,2,3,4,5,6,7,8,9,10], you plot

x = [0,1,2,3,4,5,6,7,8,9]
y = [1,2,3,4,5,6,7,8,9,10]
plt.plot(x,y)

In the case of y=[2,4,6,8,10], it'll be

x = [0,1,2,3,4]
y = [2,4,6,8,10]
plt.plot(x,y)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.