-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_fig3.py
98 lines (79 loc) · 2.3 KB
/
plot_fig3.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
import arviz as az
import cmasher as cmr
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
import seaborn as sns
import xgi
import fig_settings as fs
from lcs import *
fs.set_fonts()
with open(f"Data/zkc_tmax_comparison.json") as file:
data = json.load(file)
tmax = np.array(data["tmax"], dtype=float)
A = np.array(data["A"], dtype=float)
node_performance_simple = np.array(data["node-performance-simple"], dtype=float)
node_performance_complex = np.array(data["node-performance-complex"], dtype=float)
xmin = tmax.min()
xmax = tmax.max()
ymin = -0.2
ymax = 0.2
n, n_t, n_r = node_performance_simple.shape
G = nx.Graph(A.astype(int))
kc = nx.core_number(G)
coreness = np.zeros(n)
coreness[list(kc)] = list(kc.values())
H = xgi.Hypergraph([[i, j] for i, j in G.edges])
# plotting settings
colormap = cmr.redshift
clist = [colormap(0.15), colormap(0.3), colormap(0.7), colormap(0.85)]
## Coreness difference
ms = 4
alpha = 1
x = tmax
plt.figure(figsize=(4, 3.5))
core_values = np.unique(coreness)
for idx, k in enumerate(core_values):
n_k = sum(coreness == k)
y = node_performance_complex[coreness == k] - node_performance_simple[coreness == k]
# combine first and last axes.
y = np.array([y[i, :, j] for i in range(n_k) for j in range(n_r)]).T
ymean = np.median(y, axis=1)
hdpi_a = np.zeros_like(tmax)
hdpi_b = np.zeros_like(tmax)
for i in range(len(tmax)):
interval = az.hdi(y[i], hdi_prob=0.5)
a, b = interval
hdpi_a[i] = a
hdpi_b[i] = b
plt.semilogx(
x,
ymean,
"o-",
markersize=ms,
color=clist[idx],
alpha=alpha,
label=f"{int(k)}-core",
)
plt.fill_between(x, hdpi_a, hdpi_b, color=clist[idx], alpha=0.1)
plt.semilogx([xmin, xmax], [0, 0], "k--")
plt.xlim([xmin, xmax])
plt.ylim([ymin, ymax])
plt.xticks(
[10**1, 10**2, 10**3, 10**4],
[
r"$\mathregular{10^1}$",
r"$\mathregular{10^2}$",
r"$\mathregular{10^3}$",
r"$\mathregular{10^4}$",
],
)
plt.yticks([-0.2, -0.1, 0, 0.1, 0.2])
plt.legend(frameon=False, loc="upper left")
plt.ylabel(r"$\Delta\,\phi_i$")
plt.xlabel(r"$T$")
sns.despine()
plt.tight_layout()
plt.savefig("Figures/Fig3/fig3.png", dpi=1000)
plt.savefig("Figures/Fig3/fig3.pdf", dpi=1000)
# plt.show()