-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplots.py
162 lines (116 loc) · 5.08 KB
/
plots.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from matplotlib import pyplot as plt
import numpy as np
for plt_nsites in range(1, 20 + 1): #[4, 6, 8]
for plt_nqubits0 in range(1, plt_nsites + 1):
x1 = []
x2 = []
x3 = []
x4 = []
y1 = []
y2 = []
y3 = []
y4 = []
e = []
m = []
hm = []
with open('data.tsv') as f:
lines = f.readlines()
for line in lines:
min_loss = float(line.split()[1])
nsites = int(line.split()[3])
nqubits0 = int(line.split()[4])
h = float(line.split()[5])
nlayers = int(line.split()[6])
entropy = float(line.split()[7])
if nsites == plt_nsites:
if nqubits0 == plt_nqubits0:
if nlayers == 1:
x1.append(h)
y1.append(min_loss)
e.append(entropy)
elif nlayers == 2:
x2.append(h)
y2.append(min_loss)
elif nlayers == 3:
x3.append(h)
y3.append(min_loss)
elif nlayers == 4:
x4.append(h)
y4.append(min_loss)
if x1 or x2 or x3 or x4:
fig, axs = plt.subplots(ncols=2, nrows=2, sharex = True)
v_labelsize = 7
v_fontsize = 8
ax = axs[0,0]
ax.scatter(x1, y1, s=5, c = 'blue', marker='o', label="1 layer")
ax.set_ylabel("min_loss")
ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
ax.legend(fontsize=v_fontsize)
ax.tick_params(labelsize=v_labelsize)
ax.yaxis.get_offset_text().set_fontsize(v_fontsize)
ax = axs[0,1]
ax.scatter(x2, y2, s=5, c = 'green', marker="o", label="2 layers")
ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
ax.legend(fontsize=v_fontsize)
ax.tick_params(labelsize=v_labelsize)
ax.yaxis.get_offset_text().set_fontsize(v_fontsize)
ax = axs[1,0]
ax.scatter(x3, y3, s=5, c = 'orange', marker="o", label="3 layers")
ax.set_xlabel("h")
ax.set_ylabel("min_loss")
ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
ax.legend(fontsize=v_fontsize)
ax.tick_params(labelsize=v_labelsize)
ax.yaxis.get_offset_text().set_fontsize(v_fontsize)
ax = axs[1,1]
ax.scatter(x4, y4, s=5, c = 'red', marker="o", label="4 layers")
ax.set_xlabel("h")
ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
ax.legend(fontsize=v_fontsize)
ax.tick_params(labelsize=v_labelsize)
ax.yaxis.get_offset_text().set_fontsize(v_fontsize)
figure_name = str(plt_nsites) + " nsites, " + str(plt_nqubits0) + " nqubits0"
fig.suptitle(figure_name)
plt.savefig(figure_name + ".png", dpi=400)
if e and plt_nqubits0 == 1:
fig, axs = plt.subplots(ncols=1, nrows=1)
v_labelsize = 7
v_fontsize = 8
ax = axs
ax.scatter(x1, e, s=5, c = 'purple', marker='o')
ax.set_ylabel("Entropy")
ax.set_xlabel("h")
ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
ax.tick_params(labelsize=v_labelsize)
ax.yaxis.get_offset_text().set_fontsize(v_fontsize)
figure_name = "Entropy " + str(plt_nsites) + " nsites"
fig.suptitle(figure_name)
plt.savefig(figure_name + ".png", dpi=400)
with open('Prova3.tsv') as f:
lines = f.readlines()
for line in lines:
nsites = int(line.split()[0])
nqubits0 = int(line.split()[1])
h = float(line.split()[2])
nlayers = int(line.split()[3])
entropy = float(line.split()[4])
magnet = float(line.split()[5])
if nsites == plt_nsites:
if nqubits0 == plt_nqubits0:
if nlayers == 1:
hm.append(h)
m.append(magnet)
if m:
fig, axs = plt.subplots(ncols=1, nrows=1)
v_labelsize = 7
v_fontsize = 8
ax = axs
ax.scatter(hm, m, s=5, c = 'purple', marker='o')
ax.set_ylabel("Magnetization")
ax.set_xlabel("h")
ax.ticklabel_format(axis='y', style='sci', scilimits=(0,0))
ax.tick_params(labelsize=v_labelsize)
ax.yaxis.get_offset_text().set_fontsize(v_fontsize)
figure_name = "Magnetization " + str(plt_nsites) + " nsites"
fig.suptitle(figure_name)
plt.savefig(figure_name + ".png", dpi=400)