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
|
#!/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 ()
|