March 2014
Beginner to intermediate
222 pages
4h 7m
English
NumPy is not required to use matplotlib. However, many matplotlib tricks, code samples, and examples use NumPy. A short introduction to NumPy usage will show you the reason.
Along with having Python and matplotlib installed, you also have NumPy installed. You have a text editor and a command terminal.
Let's plot another curve, sin(x), with x in the [0, 2 * pi] interval. The only difference with the preceding script is the part where we generate the point coordinates. Type and save the following script as sin-1.py:
import math import matplotlib.pyplot as plt T = range(100) X = [(2 * math.pi * t) / len(T) for t in T] Y = [math.sin(value) for value in X] plt.plot(X, Y) plt.show()
Then, type and save the following ...
Read now
Unlock full access