summaryrefslogtreecommitdiff
path: root/project/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'project/scripts')
-rwxr-xr-xproject/scripts/cos_pi_x.py36
-rwxr-xr-xproject/scripts/minus_one_exp_x.py36
-rwxr-xr-xproject/scripts/minus_one_scatter.py34
-rwxr-xr-xproject/scripts/sin_pi_x.py36
4 files changed, 142 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 ()
+
diff --git a/project/scripts/minus_one_exp_x.py b/project/scripts/minus_one_exp_x.py
new file mode 100755
index 0000000..7073b47
--- /dev/null
+++ b/project/scripts/minus_one_exp_x.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+
+
+from mpl_toolkits.mplot3d import Axes3D
+import numpy as np
+import matplotlib.pyplot as plt
+
+
+plt.rcParams['legend.fontsize'] = 10
+
+fig = plt.figure ()
+ax = fig.gca (projection='3d')
+
+# the z-axis is vertical in matplotlib
+x = np.linspace (-2, 2, 5000)
+y = np.sin (np.pi * x)
+z = np.cos (np.pi * x)
+
+ax.plot (x, y, z, label='$y=(-1)^{x}$')
+ax.legend ()
+
+ax.set_xlabel ('x', labelpad=7)
+ax.set_xticks ([-2, -1, 0, 1, 2])
+ax.xaxis.set_rotate_label (False)
+
+ax.set_ylabel ('$y_{im}$', labelpad=7)
+ax.set_yticks ([1, 0.5, 0, -0.5, -1])
+ax.invert_yaxis ()
+ax.yaxis.set_rotate_label (False)
+
+ax.set_zlabel ('$y_{re}$', labelpad=7)
+ax.set_zticks ([-1, -0.5, 0, 0.5, 1])
+ax.zaxis.set_rotate_label (False)
+
+plt.show ()
+
diff --git a/project/scripts/minus_one_scatter.py b/project/scripts/minus_one_scatter.py
new file mode 100755
index 0000000..4b26a4f
--- /dev/null
+++ b/project/scripts/minus_one_scatter.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+
+import numpy as np
+import matplotlib.pyplot as plt
+
+
+plt.rcParams['legend.fontsize'] = 10
+
+fig = plt.figure ()
+ax = fig.gca ()
+
+data = np.array([
+ [-2, 1],
+ [-1,-1],
+ [ 0, 1],
+ [ 1,-1],
+ [ 2, 1]
+])
+x, y = data.T
+
+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.scatter (x, y, label='$y=(-1)^{x}$')
+ax.legend ()
+
+plt.show ()
+
diff --git a/project/scripts/sin_pi_x.py b/project/scripts/sin_pi_x.py
new file mode 100755
index 0000000..8436726
--- /dev/null
+++ b/project/scripts/sin_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.sin (np.pi * x)
+
+ax.plot (x, y, label='$y=Im((-1)^{x})$')
+ax.legend ()
+
+a, b = 0, 1
+ix = np.linspace (a, b)
+iy = np.sin (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 ()
+