Basic numerics and plotting with Python

try:
    import matplotlib.pyplot as plt
except ImportError:
    raise RuntimeError("This script needs the matplotlib library")

A simple example of basic Python numerics and how to plot it.

# import numpy: the module providing numerical arrays
import numpy as np

t = np.linspace(1, 10, 2000)

plt.plot(t, np.cos(t))
plot python 101
[<matplotlib.lines.Line2D object at 0x7ff5c7bf9a30>]

Total running time of the script: (0 minutes 0.193 seconds)

Estimated memory usage: 110 MB

Gallery generated by Sphinx-Gallery