-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfigure_4_special_plotting.py
More file actions
75 lines (57 loc) · 2.27 KB
/
figure_4_special_plotting.py
File metadata and controls
75 lines (57 loc) · 2.27 KB
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
import matplotlib.pyplot as plt
import numpy as np
import h5py
import seaborn as sns
import plot_format
plot_format.set_format()
data_file = h5py.File("figure_4c.h5", "r")
data_file_cont = h5py.File("figure_4_specialmain.h5", "r")
#data_file = h5py.File("extra_fine_discrete.h5", "r")
key = "foo"
TE_vals = data_file[key]["TE"]
num_events = data_file[key]["num_target_events"]
dt = data_file[key]["dt"].value
key = "bar"
TE_vals_cont = data_file_cont[key]["TE"]
fig, axs = plt.subplots(nrows = TE_vals.shape[2], figsize = (8, 16))
plt.tight_layout()
for i in range(TE_vals.shape[2]):
means = []
stds = []
for j in range(TE_vals.shape[1]):
cleaned = TE_vals[TE_vals[:, j, i] != -100, j, i]
means.append(np.mean(cleaned))
stds.append(np.std(cleaned))
means = np.array(means)
stds = np.array(stds)
means_cont = []
stds_cont = []
for j in range(TE_vals.shape[1]):
cleaned = TE_vals_cont[TE_vals_cont[:, j, i] != -100, j, i]
means_cont.append(np.mean(cleaned))
stds_cont.append(np.std(cleaned))
means_cont = np.array(means_cont)
stds_cont = np.array(stds_cont)
sns.lineplot(x = num_events, y = means, palette = "Set3", linewidth = 4, ax = axs[i])
axs[i].fill_between(num_events, means - stds, means + stds, alpha = 0.5)
sns.lineplot(x = num_events, y = means_cont, palette = "Set3", linewidth = 4, ax = axs[i])
axs[i].fill_between(num_events, means_cont - stds_cont, means_cont + stds_cont, alpha = 0.5)
axs[i].hlines(0.5076, 0, num_events[-1], color = "black", linewidth = 3)
axs[i].hlines(0.0, 0.0, num_events[-1], color = "black", linewidth = 2, linestyle='--')
axs[i].set_xscale("log")
axs[i].set_ylim([-0.1, 1.8])
axs[i].set_title("$\Delta t$ = " + str(dt[i]))
#axs[i].yaxis.set_major_formatter(FormatStrFormatter('%.2f'))
#axs[i].xaxis.set_major_formatter(LogFormatterSciNotation('%.2f'))
axs[3].set_ylabel("TE (nats/second)")
axs[0].set_xlabel("")
axs[1].set_xlabel("")
axs[2].set_xlabel("")
#axs[3].set_xlabel("Number of Target Events")
axs[3].set_xlabel("")
axs[4].set_xlabel("")
#axs[5].set_xlabel("")
axs[5].set_xlabel("Number of Target Events")
plt.subplots_adjust(hspace = 0.4)
#plt.show()
plt.savefig("discrete_v_continuous.pdf", bbox_inches='tight', format = "pdf")