Trying curve plotting

Our first problem will require you to draw a function with pyplot. Drawing a function is quite straightforward; you just have to get a series of x coordinates and map them to the y axis by using the function that you want to plot. Since the mapping results are stored away into two vectors, the plot function will deal with the curve representation. The precision of the representation will be greater if the mapped points are enough (50 points is a good sampling number):

In: import numpy as np    import matplotlib.pyplot as plt    x = np.linspace(0, 5, 50)    y_cos = np.cos(x)    y_sin = np.sin(x)   

Using the NumPy linspace() function, we will create a series of 50 equally distanced numbers ranging from 0 to 5. We can use them to map ...

Get Python Data Science Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.