English

On providing a single list or array to the plot() function, can matplotlib generate values for both the x and y axiz?

Advertisements
Advertisements

Question

On providing a single list or array to the plot() function, can matplotlib generate values for both the x and y axiz?

Short Answer
Advertisements

Solution

  • Yes, when only a single list or array is provided to the plot() function, Matplotlib automatically generates the values for the x-axis.
  • The given list values are taken as y-axis values, and the x-axis values are generated automatically starting from 0.
import matplotlib.pyplot as plt
plt.plot([10, 20, 30, 40])
plt.show()
shaalaa.com
  Is there an error in this question or solution?
Chapter 4: Plotting Data using Matplotlib - Intext Questions [Page 109]

APPEARS IN

NCERT Informatics Practices [English] Class 12
Chapter 4 Plotting Data using Matplotlib
Intext Questions | Q 1. | Page 109
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×