Think & Reflect · Q1
Q.On providing a single list or array to the plot() function, can matplotlib generate values for both the x and y axis?
Rajasthan RbseTextbookSubjective· 2mImportance★★★★★est
86% · 38/44 Questions
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →No — matplotlib generates values for only ONE axis, not both.
Passing a single list/array to plt.plot(y) makes matplotlib auto-generate the x-values as the index positions (0, 1, 2, ...); the values you supplied become the y-values. It does not invent data for both axes — your one list is always the y-data.
Step by step
plt.plot(y)is called with ONE sequence.- Matplotlib needs an x-value for every point it draws, so it manufactures one axis for you: the position of each value in the list -- 0, 1, 2, 3, ... -- becomes x.
- Your supplied list becomes the y-values, unchanged. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.