Skip to content

Commit

Permalink
Fix fonts (#24)
Browse files Browse the repository at this point in the history
* make fontsizes consistent across figures

* rmove old plots

* updated fontsize
  • Loading branch information
nwlandry authored Feb 13, 2024
1 parent 1f0811f commit 79b93ec
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 8,269 deletions.
87 changes: 42 additions & 45 deletions Extra/plot_fig1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"\n",
"\n",
"# Set the global default size of the axis labels\n",
"plt.rcParams['axes.labelsize'] = 20\n",
"plt.rcParams[\"axes.labelsize\"] = 20\n",
"# Set the global default size of the tick labels\n",
"plt.rcParams['xtick.labelsize'] = 15\n",
"plt.rcParams['ytick.labelsize'] = 15\n",
"plt.rcParams['axes.titlesize'] = 25\n",
"plt.rcParams['legend.fontsize'] = 15\n",
"plt.rcParams['xtick.major.size'] = 7 # length in points\n"
"plt.rcParams[\"xtick.labelsize\"] = 15\n",
"plt.rcParams[\"ytick.labelsize\"] = 15\n",
"plt.rcParams[\"axes.titlesize\"] = 25\n",
"plt.rcParams[\"legend.fontsize\"] = 15\n",
"plt.rcParams[\"xtick.major.size\"] = 7 # length in points"
]
},
{
Expand All @@ -40,10 +40,10 @@
"metadata": {},
"outputs": [],
"source": [
"#pallete = [\"#F8B195\",\"#355C7D\",\"#F67280\",\"#C06C84\",\"#6C5B7B\"]\n",
"pallete = [\"#355C7D\",\"#F67280\",\"#F8B195\",\"#C06C84\",\"#6C5B7B\"]\n",
"mpl.rcParams['axes.prop_cycle'] = mpl.cycler(color= pallete)\n",
"cmap = mcolors.LinearSegmentedColormap.from_list('my_cmap',[pallete[0],pallete[1]])"
"# pallete = [\"#F8B195\",\"#355C7D\",\"#F67280\",\"#C06C84\",\"#6C5B7B\"]\n",
"pallete = [\"#355C7D\", \"#F67280\", \"#F8B195\", \"#C06C84\", \"#6C5B7B\"]\n",
"mpl.rcParams[\"axes.prop_cycle\"] = mpl.cycler(color=pallete)\n",
"cmap = mcolors.LinearSegmentedColormap.from_list(\"my_cmap\", [pallete[0], pallete[1]])"
]
},
{
Expand Down Expand Up @@ -97,7 +97,7 @@
"\n",
"x = contagion_process(A, gamma, c, x0, tmin=0, tmax=100, random_seed=2)\n",
"\n",
"infected_color = 'C1' \n",
"infected_color = \"C1\"\n",
"susceptible_color = \"white\"\n",
"subgraph_color = \"black\"\n",
"graph_color = (0.1, 0.1, 0.1, 0.1)\n",
Expand All @@ -111,7 +111,7 @@
"pos = xgi.pca_transform(xgi.pairwise_spring_layout(H, seed=5, k=0.3))\n",
"node_fc = [infected_color if x[t, i] else susceptible_color for i in H.nodes]\n",
"node_ec = [subgraph_node_lc if n in nbrs else graph_node_lc for n in H.nodes]\n",
"node_fc[12] = 'C0'\n",
"node_fc[12] = \"C0\"\n",
"\n",
"dyad_color = [subgraph_color if e in sg else graph_color for e in H.edges]\n",
"\n",
Expand Down Expand Up @@ -245,7 +245,7 @@
"\n",
"# simple contagion\n",
"c1_mean = c1_samples.mean(axis=0)\n",
"plt.plot(nus, c1, \"-\", color='C0', label=\"Simple contagion\")\n",
"plt.plot(nus, c1, \"-\", color=\"C0\", label=\"Simple contagion\")\n",
"# plt.scatter(nus, c1_mean, linewidth=0.5, color=colors[2])\n",
"\n",
"err_c1 = np.zeros((2, n))\n",
Expand All @@ -255,11 +255,11 @@
" x, y = interval\n",
" err_c1[0, i] = max(c1_mean[i] - x, 0)\n",
" err_c1[1, i] = max(y - c1_mean[i], 0)\n",
"plt.errorbar(nus, c1_mean, err_c1, color='C0', fmt=\"o\")\n",
"plt.errorbar(nus, c1_mean, err_c1, color=\"C0\", fmt=\"o\")\n",
"\n",
"# threshold contagion, tau=2\n",
"c2_mean = c2_samples.mean(axis=0)\n",
"plt.plot(nus, c2, \"-\", color='C1', label=\"Complex contagion\")\n",
"plt.plot(nus, c2, \"-\", color=\"C1\", label=\"Complex contagion\")\n",
"# plt.scatter(nus, c2_mean, linewidth=0.5, color=colors[1])\n",
"\n",
"err_c2 = np.zeros((2, n))\n",
Expand All @@ -269,7 +269,7 @@
" x, y = interval\n",
" err_c2[0, i] = max(c2_mean[i] - x, 0)\n",
" err_c2[1, i] = max(y - c2_mean[i], 0)\n",
"plt.errorbar(nus, c2_mean, err_c2, color='C1', fmt=\"o\")\n",
"plt.errorbar(nus, c2_mean, err_c2, color=\"C1\", fmt=\"o\")\n",
"\n",
"plt.xticks(np.arange(0, n, 5))\n",
"plt.xlabel(r\"$\\nu$\")\n",
Expand Down Expand Up @@ -310,7 +310,7 @@
"with open(\"Data/zkc_infer_vs_tmax.json\") as file:\n",
" data = json.load(file)\n",
"\n",
"#colors = [\"steelblue\", \"darksalmon\", \"mediumseagreen\"]\n",
"# colors = [\"steelblue\", \"darksalmon\", \"mediumseagreen\"]\n",
"colors = pallete\n",
"\n",
"tmax = data[\"tmax\"]\n",
Expand All @@ -320,22 +320,22 @@
"\n",
"fig = plt.figure(figsize=(4, 3))\n",
"\n",
"#plt.semilogx(tmax, sps[0].mean(axis=1), color=colors[2], label=\"Simple contagion\")\n",
"plt.semilogx(tmax, sps[0].mean(axis=1), color='C0', label=\"Simple contagion\")\n",
"plt.semilogx(tmax, sps[1].mean(axis=1), color='C1', label=\"Complex contagion\")\n",
"# plt.semilogx(tmax, sps[0].mean(axis=1), color=colors[2], label=\"Simple contagion\")\n",
"plt.semilogx(tmax, sps[0].mean(axis=1), color=\"C0\", label=\"Simple contagion\")\n",
"plt.semilogx(tmax, sps[1].mean(axis=1), color=\"C1\", label=\"Complex contagion\")\n",
"plt.fill_between(\n",
" tmax,\n",
" sps[0].mean(axis=1) - sps[0].std(axis=1),\n",
" sps[0].mean(axis=1) + sps[0].std(axis=1),\n",
" alpha=0.3,\n",
" color='C0',\n",
" color=\"C0\",\n",
")\n",
"plt.fill_between(\n",
" tmax,\n",
" sps[1].mean(axis=1) - sps[1].std(axis=1),\n",
" sps[1].mean(axis=1) + sps[1].std(axis=1),\n",
" alpha=0.3,\n",
" color='C1',\n",
" color=\"C1\",\n",
")\n",
"plt.ylabel(\"F-Score\")\n",
"plt.xlabel(r\"$t_{max}$\")\n",
Expand Down Expand Up @@ -373,7 +373,7 @@
"sps = np.array(data[\"sps\"], dtype=float)\n",
"fce = np.array(data[\"fce\"], dtype=float)\n",
"\n",
"#cmap = cmr.gem\n",
"# cmap = cmr.gem\n",
"cmap = cmap\n",
"\n",
"sps_summary = sps.mean(axis=2)\n",
Expand Down Expand Up @@ -428,7 +428,9 @@
}
],
"source": [
"fig, ((ax1, ax2),(ax3, ax4)) = plt.subplots(2,2,figsize=(8,6), sharey=False, sharex=False)\n",
"fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(\n",
" 2, 2, figsize=(8, 6), sharey=False, sharex=False\n",
")\n",
"\n",
"\"\"\"\n",
"Panel 1: Network Viz\n",
Expand All @@ -450,7 +452,7 @@
"\n",
"x = contagion_process(A, gamma, c, x0, tmin=0, tmax=100, random_seed=2)\n",
"\n",
"infected_color = 'C1' \n",
"infected_color = \"C1\"\n",
"susceptible_color = \"white\"\n",
"subgraph_color = \"black\"\n",
"graph_color = (0.1, 0.1, 0.1, 0.1)\n",
Expand All @@ -464,12 +466,11 @@
"pos = xgi.pca_transform(xgi.pairwise_spring_layout(H, seed=5, k=0.3))\n",
"node_fc = [infected_color if x[t, i] else susceptible_color for i in H.nodes]\n",
"node_ec = [subgraph_node_lc if n in nbrs else graph_node_lc for n in H.nodes]\n",
"node_fc[12] = 'C0'\n",
"node_fc[12] = \"C0\"\n",
"\n",
"dyad_color = [subgraph_color if e in sg else graph_color for e in H.edges]\n",
"\n",
"\n",
"\n",
"xgi.draw(\n",
" H,\n",
" pos=pos,\n",
Expand All @@ -478,7 +479,7 @@
" dyad_color=dyad_color,\n",
" node_ec=node_ec,\n",
" node_lw=0.5,\n",
" ax = ax1\n",
" ax=ax1,\n",
")\n",
"\n",
"# plt.savefig(\"Figures/Fig1/zkc_network.svg\", dpi=1000)\n",
Expand Down Expand Up @@ -517,7 +518,7 @@
"\n",
"# simple contagion\n",
"c1_mean = c1_samples.mean(axis=0)\n",
"ax2.plot(nus, c1, \"-\", color='C0', label=\"Simple contagion\")\n",
"ax2.plot(nus, c1, \"-\", color=\"C0\", label=\"Simple contagion\")\n",
"# ax2.scatter(nus, c1_mean, linewidth=0.5, color=colors[2])\n",
"\n",
"err_c1 = np.zeros((2, n))\n",
Expand All @@ -527,11 +528,11 @@
" x, y = interval\n",
" err_c1[0, i] = max(c1_mean[i] - x, 0)\n",
" err_c1[1, i] = max(y - c1_mean[i], 0)\n",
"ax2.errorbar(nus, c1_mean, err_c1, color='C0', fmt=\"o\")\n",
"ax2.errorbar(nus, c1_mean, err_c1, color=\"C0\", fmt=\"o\")\n",
"\n",
"# threshold contagion, tau=2\n",
"c2_mean = c2_samples.mean(axis=0)\n",
"ax2.plot(nus, c2, \"-\", color='C1', label=\"Complex contagion\")\n",
"ax2.plot(nus, c2, \"-\", color=\"C1\", label=\"Complex contagion\")\n",
"# ax2.scatter(nus, c2_mean, linewidth=0.5, color=colors[1])\n",
"\n",
"err_c2 = np.zeros((2, n))\n",
Expand All @@ -541,7 +542,7 @@
" x, y = interval\n",
" err_c2[0, i] = max(c2_mean[i] - x, 0)\n",
" err_c2[1, i] = max(y - c2_mean[i], 0)\n",
"ax2.errorbar(nus, c2_mean, err_c2, color='C1', fmt=\"o\")\n",
"ax2.errorbar(nus, c2_mean, err_c2, color=\"C1\", fmt=\"o\")\n",
"\n",
"ax2.set_xticks(np.arange(0, n, 5))\n",
"ax2.set_xlabel(r\"$\\nu$\")\n",
Expand All @@ -563,7 +564,7 @@
"with open(\"Data/zkc_infer_vs_tmax.json\") as file:\n",
" data = json.load(file)\n",
"\n",
"#colors = [\"steelblue\", \"darksalmon\", \"mediumseagreen\"]\n",
"# colors = [\"steelblue\", \"darksalmon\", \"mediumseagreen\"]\n",
"colors = pallete\n",
"\n",
"tmax = data[\"tmax\"]\n",
Expand All @@ -572,22 +573,22 @@
"fce = np.array(data[\"fce\"], dtype=float)\n",
"\n",
"\n",
"#ax3.semilogx(tmax, sps[0].mean(axis=1), color=colors[2], label=\"Simple contagion\")\n",
"ax3.semilogx(tmax, sps[0].mean(axis=1), color='C0', label=\"Simple contagion\")\n",
"ax3.semilogx(tmax, sps[1].mean(axis=1), color='C1', label=\"Complex contagion\")\n",
"# ax3.semilogx(tmax, sps[0].mean(axis=1), color=colors[2], label=\"Simple contagion\")\n",
"ax3.semilogx(tmax, sps[0].mean(axis=1), color=\"C0\", label=\"Simple contagion\")\n",
"ax3.semilogx(tmax, sps[1].mean(axis=1), color=\"C1\", label=\"Complex contagion\")\n",
"ax3.fill_between(\n",
" tmax,\n",
" sps[0].mean(axis=1) - sps[0].std(axis=1),\n",
" sps[0].mean(axis=1) + sps[0].std(axis=1),\n",
" alpha=0.3,\n",
" color='C0',\n",
" color=\"C0\",\n",
")\n",
"ax3.fill_between(\n",
" tmax,\n",
" sps[1].mean(axis=1) - sps[1].std(axis=1),\n",
" sps[1].mean(axis=1) + sps[1].std(axis=1),\n",
" alpha=0.3,\n",
" color='C1',\n",
" color=\"C1\",\n",
")\n",
"ax3.set_ylabel(\"F-Score\")\n",
"ax3.set_xlabel(r\"$t_{max}$\")\n",
Expand All @@ -596,7 +597,6 @@
"sns.despine()\n",
"\n",
"\n",
"\n",
"with open(\"Data/zkc_frac_vs_beta.json\") as file:\n",
" data = json.load(file)\n",
"beta = np.array(data[\"beta\"], dtype=float)\n",
Expand All @@ -605,7 +605,7 @@
"sps = np.array(data[\"sps\"], dtype=float)\n",
"fce = np.array(data[\"fce\"], dtype=float)\n",
"\n",
"#cmap = cmr.gem\n",
"# cmap = cmr.gem\n",
"cmap = cmap\n",
"\n",
"sps_summary = sps.mean(axis=2)\n",
Expand All @@ -625,11 +625,8 @@
"ax4.set_xticks([0, 0.5, 1], [0, 0.5, 1])\n",
"ax4.set_yticks([0, 0.25, 0.5, 0.75, 1], [0, 0.25, 0.5, 0.75, 1])\n",
"\n",
"cbar = plt.colorbar(c,ax = ax4)\n",
"cbar.set_label(r\"F-Score\", fontsize=12, rotation=270, labelpad=15)\n",
"\n",
"\n",
"\n"
"cbar = plt.colorbar(c, ax=ax4)\n",
"cbar.set_label(r\"F-Score\", fontsize=12, rotation=270, labelpad=15)"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion Extra/plot_fig2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"import xgi\n",
"\n",
"import fig_settings as fs\n",
"\n",
"cmap = fs.cmap\n",
"\n",
"\n",
Expand All @@ -28,7 +29,7 @@
"outputs": [],
"source": [
"fs.set_fonts({\"font.family\": \"sans-serif\"})\n",
"#cmap = cmr.gem"
"# cmap = cmr.gem"
]
},
{
Expand Down
Binary file removed Figures/Fig1/figure1_4panel.pdf
Binary file not shown.
Binary file removed Figures/Fig1/figure1_4panel.png
Binary file not shown.
Binary file modified Figures/Fig1/illustration.pdf
Binary file not shown.
Binary file added Figures/Fig1/illustration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 79b93ec

Please sign in to comment.