Skip to content

Commit

Permalink
adjusted text label positions and AUROC cbar range (#36)
Browse files Browse the repository at this point in the history
* adjusted text label positions and AUROC cbar range

* unifed HDI to 80%, switched to median AUROC so that it sits closer to the middle of said hdi

* Figure 2 tweaks

* Figure 3 tweaks

* 50% hdpi and median everywhere

* sizing
  • Loading branch information
jg-you authored Apr 30, 2024
1 parent 58dd39f commit 479513e
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 39 deletions.
Binary file modified Figures/Fig1/fig1.pdf
Binary file not shown.
Binary file modified Figures/Fig1/fig1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Figures/Fig2/fig2.pdf
Binary file not shown.
Binary file modified Figures/Fig2/fig2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Figures/Fig3/fig3.pdf
Binary file not shown.
Binary file modified Figures/Fig3/fig3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions fig_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
# color styling
def set_colors(n_colors=2):
global cmap
global auroc_cmap
global pallette
cmap = "cmr.redshift"
qualitative_cmap = cmr.get_sub_cmap(cmap, 0.2, 0.8, N=n_colors)
auroc_cmap = cmr.get_sub_cmap(cmap, 0.5, 1)

pallette = qualitative_cmap.colors
mpl.rcParams["axes.prop_cycle"] = mpl.cycler(color=pallette)
Expand Down
44 changes: 22 additions & 22 deletions plot_fig1.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
ax1.set_position([0, 0.4, 0.45, 0.75])

ax1.text(
0.025,
0.775,
0.01,
0.79,
"(a)",
transform=ax1.transAxes,
fontsize=13,
Expand Down Expand Up @@ -111,7 +111,7 @@
ax2 = fig.add_subplot(gs[1])
ax2.text(
-0.39,
1.1,
1.13,
"(b)",
transform=ax2.transAxes,
fontsize=12,
Expand Down Expand Up @@ -140,7 +140,7 @@

err_c1 = np.zeros((2, n))
for i in range(n):
interval = az.hdi(c1_samples[:, i], hdi_prob=0.95)
interval = az.hdi(c1_samples[:, i], hdi_prob=0.5)
x, y = interval
err_c1[0, i] = max(c1_mean[i] - x, 0)
err_c1[1, i] = max(y - c1_mean[i], 0)
Expand All @@ -165,7 +165,7 @@

err_c2 = np.zeros((2, n))
for i in range(n):
interval = az.hdi(c2_samples[:, i], alpha=0.05, roundto=4)
interval = az.hdi(c2_samples[:, i], hdi_prob=0.5)
x, y = interval
err_c2[0, i] = max(c2_mean[i] - x, 0)
err_c2[1, i] = max(y - c2_mean[i], 0)
Expand Down Expand Up @@ -203,8 +203,8 @@
"""
ax3 = fig.add_subplot(gs[2])
ax3.text(
-0.35,
1.05,
-0.37,
1.11,
"(c)",
transform=ax3.transAxes,
fontsize=12,
Expand All @@ -219,12 +219,12 @@
tmax = np.array(data["tmax"], dtype=float)
performance = np.array(data[measure], dtype=float)

ax3.semilogx(tmax, performance[0].mean(axis=1), color="C0", label="Simple")
ax3.semilogx(tmax, performance[1].mean(axis=1), color="C1", label="Complex")
min_idx = np.where((performance[0].mean(axis=1) - performance[1].mean(axis=1)) < 0)[
ax3.semilogx(tmax, np.median(performance[0], axis=1), color="C0", label="Simple")
ax3.semilogx(tmax, np.median(performance[1], axis=1), color="C1", label="Complex")
min_idx = np.where((np.median(performance[0], axis=1) - np.median(performance[1], axis=1)) < 0)[
0
].min()
max_idx = np.where((performance[0].mean(axis=1) - performance[1].mean(axis=1)) < 0)[
max_idx = np.where((np.median(performance[0], axis=1) - np.median(performance[1], axis=1)) < 0)[
0
].max()
print(tmax[min_idx])
Expand All @@ -233,7 +233,7 @@
hdi_a = np.zeros_like(tmax)
hdi_b = np.zeros_like(tmax)
for i in range(len(tmax)):
interval = az.hdi(performance[0, i], hdi_prob=0.95)
interval = az.hdi(performance[0, i], hdi_prob=0.5)
a, b = interval
hdi_a[i] = a
hdi_b[i] = b
Expand All @@ -243,14 +243,14 @@
hdi_a = np.zeros_like(tmax)
hdi_b = np.zeros_like(tmax)
for i in range(len(tmax)):
interval = az.hdi(performance[1, i], hdi_prob=0.95)
interval = az.hdi(performance[1, i], hdi_prob=0.5)
a, b = interval
hdi_a[i] = a
hdi_b[i] = b

ax3.fill_between(tmax, hdi_a, hdi_b, alpha=0.3, color="C1", edgecolor="none")
ax3.set_ylabel(measure.upper())
ax3.set_xlabel(r"$t_{\mathregular{max}}$")
ax3.set_xlabel(r"Time series length, $T$")
ax3.set_xlim([10, 10**4])
ax3.set_xticks(
[10, 100, 1000, 10000],
Expand All @@ -261,8 +261,8 @@
r"$\mathregular{10^4}$",
],
)
ax3.set_ylim([0, 1])
ax3.set_yticks([0, 0.5, 1], [0, 0.5, 1])
ax3.set_ylim([0.45, 1])
ax3.set_yticks([0.5, 1], [0.5, 1])

ax3.legend(
loc="lower right",
Expand All @@ -280,7 +280,7 @@
ax4 = fig.add_subplot(gs[3])
ax4.text(
-0.38,
1.05,
1.11,
"(d)",
transform=ax4.transAxes,
fontsize=12,
Expand All @@ -300,20 +300,20 @@
np.fliplr(to_imshow_orientation(mean_performance)),
extent=(min(frac), max(frac), max(beta), min(beta)),
aspect="auto",
cmap=cmap,
vmin=0,
cmap=fs.auroc_cmap,
vmin=0.5,
vmax=1,
)
ax4.set_xlabel(r"Complexity, $\lambda$")
ax4.set_xlabel(r"Complexity, $\omega$")
ax4.set_ylabel(r"Infectivity, $\beta$")

ax4.set_xticks([0, 0.5, 1], [0, 0.5, 1])
ax4.set_yticks([0, 0.5, 1], [0, 0.5, 1])

cbar_ax = fig.add_axes([0.91, 0.15, 0.015, 0.31]) # x, y, width, height
cbar = plt.colorbar(c, cax=cbar_ax)
cbar.set_label(measure.upper(), fontsize=axislabel_fontsize, rotation=270, labelpad=10)
cbar_ax.set_yticks([0, 1], [0, 1], fontsize=tick_fontsize)
cbar.set_label(measure.upper(), fontsize=axislabel_fontsize, rotation=270, labelpad=0)
cbar_ax.set_yticks([0.5, 1], [0.5, 1], fontsize=tick_fontsize)

plt.savefig("Figures/Fig1/fig1.png", dpi=1000)
plt.savefig("Figures/Fig1/fig1.pdf", dpi=1000)
Expand Down
6 changes: 3 additions & 3 deletions plot_fig2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
]
keys = ["p", "alpha", "size"]
titles = ["Erdös-Rényi", "Power-law CM", "Clustered"]
labels = [r"$p$", r"$\alpha$", r"$s$"]
labels = [r"Density, $p$", r"Exponent $\alpha$", r"Clique size $s$"]
xticks = [
[0, 0.5, 1],
[-4, -3, -2],
Expand Down Expand Up @@ -116,7 +116,7 @@ def visualize_networks(i, ax):
ax.plot(var, r0 * beta_c, "-", linewidth=0.25, color="grey")

if i == 0:
ax.set_ylabel(r"$\beta$")
ax.set_ylabel(r"Infectivity, $\beta$")
else:
ax.set_yticks([], [])

Expand Down Expand Up @@ -144,7 +144,7 @@ def visualize_networks(i, ax):
ax.set_yticks([0, 0.5, 1], [0, 0.5, 1])

if i == 0:
ax.set_ylabel(r"$\beta$")
ax.set_ylabel(r"Infectivity,$\beta$")
else:
ax.set_yticks([], [])

Expand Down
20 changes: 6 additions & 14 deletions plot_fig3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@
import fig_settings as fs
from lcs import *

axislabel_fontsize = 12
tick_fontsize = 12
fs.set_fonts(
{
"font.family": "serif",
"axes.labelsize": axislabel_fontsize,
"xtick.labelsize": tick_fontsize,
"ytick.labelsize": tick_fontsize,
}
)

fs.set_fonts()

with open(f"Data/zkc_tmax_comparison.json") as file:
data = json.load(file)
Expand Down Expand Up @@ -52,7 +44,7 @@

x = tmax

plt.figure(figsize=(5.5, 5))
plt.figure(figsize=(4, 3.5))

core_values = np.unique(coreness)

Expand All @@ -61,7 +53,7 @@
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 = y.mean(axis=1)
ymean = np.median(y, axis=1)

hdpi_a = np.zeros_like(tmax)
hdpi_b = np.zeros_like(tmax)
Expand All @@ -77,7 +69,7 @@
markersize=ms,
color=clist[idx],
alpha=alpha,
label=f"{int(k)}-core nodes",
label=f"{int(k)}-core",
)
plt.fill_between(x, hdpi_a, hdpi_b, color=clist[idx], alpha=0.1)

Expand All @@ -98,7 +90,7 @@

plt.legend(frameon=False, loc="upper left")
plt.ylabel(r"$\Delta\,\phi_i$")
plt.xlabel(r"$t_{\max}$")
plt.xlabel(r"$T$")
sns.despine()
plt.tight_layout()

Expand Down

0 comments on commit 479513e

Please sign in to comment.