1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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 ()
|