December 2017
Intermediate to advanced
386 pages
10h 42m
English
We start by generating the data to be plotted, with the three following statements:
xvalues = np.linspace(-np.pi, np.pi, 300)yvalues1 = np.sin(xvalues)yvalues2 = np.cos(xvalues)
We first create an xvalues array, containing 300 equally spaced values between -π and π. We then compute the sine and cosine functions of the values in xvalues, storing the results in the yvalues1 and yvalues2 arrays. Next, we generate the first line plot with the following statement:
plt.plot(xvalues, yvalues1, lw=2, color='red', label='sin(x)')
The arguments to the plot() function are described as follows:
Read now
Unlock full access