diff options
Diffstat (limited to 'project/scripts/cos_pi_x.py')
-rwxr-xr-x | project/scripts/cos_pi_x.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/project/scripts/cos_pi_x.py b/project/scripts/cos_pi_x.py new file mode 100755 index 0000000..551c142 --- /dev/null +++ b/project/scripts/cos_pi_x.py @@ -0,0 +1,36 @@ +#!/usr/bin/python + + +import numpy as np +import matplotlib.pyplot as plt +from matplotlib.patches import Polygon + + +plt.rcParams['legend.fontsize'] = 10 + +fig = plt.figure () +ax = fig.gca () + +x = np.linspace (-2, 2, 5000) +y = np.cos (np.pi * x) + +ax.plot (x, y, label='$y=Re((-1)^{x})$') +ax.legend () + +a, b = 0, 1 +ix = np.linspace (a, b) +iy = np.cos (np.pi * ix) +verts = [(a,0)] + zip (ix, iy) + [(b,0)] +poly = Polygon (verts, facecolor='0.9', edgecolor='0.5') +ax.add_patch (poly) + +ax.set_xticks ([-2, -1, 1, 2]) +ax.spines['left'].set_position ('center') +ax.spines['right'].set_position ('center') + +ax.set_yticks ([-1, -0.5, 0.5, 1]) +ax.spines['top'].set_position ('center') +ax.spines['bottom'].set_position ('center') + +plt.show () + |