-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
47 lines (31 loc) · 979 Bytes
/
plot.py
File metadata and controls
47 lines (31 loc) · 979 Bytes
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
37
38
39
40
41
42
43
44
45
46
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import ticker
name = 'LevenbergMarquardt'
def f(x, y):
return (1 - x) ** 2 + 100 * (y - x * x) ** 2
n = 256
x = np.linspace(-1, 1.1, n)
y = np.linspace(-0.1, 1.1, n)
X, Y = np.meshgrid(x, y)
plt.figure()
plt.contourf(X, Y, f(X, Y), 5, alpha=0, cmap=plt.cm.hot)
C = plt.contour(X, Y, f(X, Y), 8, locator=ticker.LogLocator(), colors='black', linewidth=0.01)
plt.clabel(C, inline=True, fontsize=10)
# ---------------------
x1 = []
x2 = []
with open('../data/' + name + '.txt') as f:
for line in f.readlines():
temp = line.split()
x1.append(float(temp[0]))
x2.append(float(temp[1]))
plt.plot(x1[0], x2[0], marker='o', color='green', markersize=10)
plt.plot(x1[len(x1)-1], x2[len(x2)-1], marker='o', color='red', markersize=10)
plt.plot(x1, x2, color='orange')
plt.xlabel('x1')
plt.ylabel('x2')
plt.title(name)
#plt.legend()
plt.savefig("./picture/" + name)
plt.show()