Plotting a curve

Plotting a line graph of the list can be as simple as:

plt.plot(evens)

When only one parameter is specified, Pyplot assumes the data we input is on the y-axis and chooses a scale for the x-axis automatically.

To plot a graph, call plt.plot(x,y) where x and y are the x coordinates and y coordinates of data points:

plt.plot(evens,evens**2)

To label the curve with a legend, we add the label information in the plot function:

plt.plot(evens,evens**2,label = 'x^2')
plt.legend()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset