Skip to content

Commit

Permalink
Changing colors in Figs 2-5
Browse files Browse the repository at this point in the history
  • Loading branch information
sipv committed Feb 15, 2023
1 parent 08b3d91 commit c111acc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 48 deletions.
18 changes: 5 additions & 13 deletions study/notebooks/Fig_HCP_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"metadata": {},
"outputs": [],
"source": [
"colors = ['tab:blue', 'tab:green']\n",
"colors = ['#006BA4', '#FF800E']\n",
"\n",
"def plot_obs_all(ax, t, y, iregs, title=None):\n",
" plt.sca(ax)\n",
Expand Down Expand Up @@ -196,7 +196,7 @@
" ax1 = plt.subplot(gs[0,0])\n",
" plot_obs_all(ax1, t, y, examples, title=\"Time series\")\n",
"\n",
" labels = \"ABCDEFGHI\"[:len(examples)] \n",
" labels = [f'R{i}' for i in range(1, len(examples)+1)]\n",
" ax2 = plt.subplot(gs[1,0])\n",
" plot_obs_lines(ax2, t, y[examples], labels=labels, offset=4, us=us)\n",
" # plt.xlim(0,150)\n",
Expand Down Expand Up @@ -297,15 +297,7 @@
" \n",
" if label:\n",
" plt.text(0.04, 0.96, label, ha='left', va='top', transform=ax.transAxes, color=color, fontsize=8, \n",
" bbox=dict(boxstyle='square', facecolor='white', alpha=0.85))\n",
" \n",
" \n",
" for pos in ['bottom', 'top', 'right', 'left']:\n",
" ax.spines[pos].set_color(color)\n",
" ax.spines[pos].set_linewidth(1.5)\n",
" ax.tick_params(axis='both', colors=color)\n",
" ax.xaxis.label.set_color(color)\n",
" ax.yaxis.label.set_color(color)"
" bbox=dict(boxstyle='square', facecolor='white', alpha=0.85))"
]
},
{
Expand Down Expand Up @@ -436,7 +428,7 @@
"plot_observations(gs1, ds.t, ds.y[isub,:,0,:], iregs)\n",
"\n",
"# Panels B\n",
"for i, (ireg, label) in enumerate(zip(iregs, ['A', 'B'])):\n",
"for i, (ireg, label) in enumerate(zip(iregs, ['R1', 'R2'])):\n",
" for j, dims in enumerate([(0,1), (0,2), (1,2)]):\n",
" truedims = order[list(dims)] \n",
" ax = plt.subplot(gs2[i,j])\n",
Expand Down Expand Up @@ -486,7 +478,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down
38 changes: 23 additions & 15 deletions study/notebooks/Fig_Hopf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"metadata": {},
"outputs": [],
"source": [
"colors = ['tab:blue', 'tab:red', 'tab:green']\n",
"colors = ['#006BA4', '#FF800E', '#595959']\n",
"\n",
"def axbottomleft(ax):\n",
" ax.spines['top'].set_visible(False)\n",
Expand All @@ -143,7 +143,7 @@
"def plot_sc(ax, cax, ds, isub):\n",
" plt.sca(ax)\n",
" plt.title(\"Structural conn.\")\n",
" im = plt.imshow(ds.w[isub], cmap='cividis', interpolation='none')\n",
" im = plt.imshow(ds.w[isub], cmap='Greys', interpolation='none')\n",
" plt.xticks([])\n",
" plt.yticks([])\n",
" plt.xlabel(\"Regions\")\n",
Expand Down Expand Up @@ -207,7 +207,7 @@
"metadata": {},
"outputs": [],
"source": [
"def plot_param2d(ax, pest, ptru=None, param_name=None, lim=None, iregs=None):\n",
"def plot_param2d(ax, pest, ptru=None, param_name=None, lim=None, iregs=None, labels=None):\n",
" plt.sca(ax) \n",
" \n",
" if lim is None:\n",
Expand All @@ -229,12 +229,20 @@
" col = colors[list(iregs).index(i)]\n",
" lw, zorder = 1, 10\n",
" except ValueError:\n",
" col = 'k' \n",
" col = '#ABABAB'\n",
" \n",
" plt.plot([pest[i,0,0]-pest[i,0,1], pest[i,0,0]+pest[i,0,1]], [pest[i,1,0], pest[i,1,0]],\n",
" color=col, lw=lw, zorder=zorder)\n",
" plt.plot([pest[i,0,0], pest[i,0,0]], [pest[i,1,0]-pest[i,1,1], pest[i,1,0]+pest[i,1,1]],\n",
" color=col, lw=lw, zorder=zorder)\n",
" \n",
" if labels is not None: \n",
" for ireg, label, col in zip(iregs, labels, colors):\n",
" ha = 'left' if pest[ireg,0,0] > 0 else 'right'\n",
" va = 'bottom' if pest[ireg,1,0] > 0 else 'top'\n",
" offset = (0.2 if ha=='left' else -0.2, 0.) \n",
" plt.text(pest[ireg,0,0]+offset[0], pest[ireg,1,0]+offset[1], label, color=col,\n",
" ha=ha, va=va, fontsize=7)\n",
" \n",
" plt.xlim(-3,3)\n",
" plt.ylim(-3,3)\n",
Expand Down Expand Up @@ -298,12 +306,12 @@
" plt.text(0.04, 0.96, label, ha='left', va='top', transform=ax.transAxes, color=color, fontsize=8,\n",
" bbox=dict(boxstyle='square', facecolor='white', alpha=0.85), zorder=20)\n",
" \n",
" for pos in ['bottom', 'top', 'right', 'left']:\n",
" ax.spines[pos].set_color(color)\n",
" ax.spines[pos].set_linewidth(1.5)\n",
" ax.tick_params(axis='both', colors=color)\n",
" ax.xaxis.label.set_color(color)\n",
" ax.yaxis.label.set_color(color) \n",
"# for pos in ['bottom', 'top', 'right', 'left']:\n",
"# ax.spines[pos].set_color(color)\n",
"# ax.spines[pos].set_linewidth(1.5)\n",
"# ax.tick_params(axis='both', colors=color)\n",
"# ax.xaxis.label.set_color(color)\n",
"# ax.yaxis.label.set_color(color)\n",
" \n",
" \n",
"def plot_params(ax, x, label, lim, cax=None):\n",
Expand Down Expand Up @@ -335,7 +343,7 @@
" plot_obs_all(ax1, t, y, examples, title=\"Time series\")\n",
"\n",
" ax2 = plt.subplot(gs[1,0])\n",
" plot_obs_lines(ax2, t, y[examples], labels=['A', 'B', 'C'], offset=4)\n",
" plot_obs_lines(ax2, t, y[examples], labels=['R1', 'R2', 'R3'], offset=4)\n",
" plt.xlim(0,150)\n",
" \n",
" plt.plot([10, 20], [5,5], lw=2, color='k', clip_on=False)\n",
Expand Down Expand Up @@ -371,7 +379,7 @@
" \n",
" for i in range(nsub):\n",
" plt.plot([ptru[i], ptru[i]], [pest[i,0]-pest[i,1], pest[i,0]+pest[i,1]], color='k', lw=0.7, zorder=10)\n",
" plt.scatter(ptru[i], pest[i,0], fc=('0.5' if i == example else 'white'), ec='k', lw=0.4, s=15)\n",
" plt.scatter(ptru[i], pest[i,0], fc=('#ABABAB' if i == example else 'white'), ec='k', lw=0.4, s=15)\n",
" \n",
" plt.xlabel(xlabel, labelpad=2)\n",
" plt.ylabel(ylabel, labelpad=0)\n",
Expand Down Expand Up @@ -422,11 +430,11 @@
"gs3b = fig.add_gridspec(nrows=3, ncols=1, left=0.21, right=0.30, top=0.56, bottom=0.08, hspace=0.15)\n",
"gs3c = fig.add_gridspec(nrows=2, ncols=1, left=0.39, right=0.50, top=0.49, bottom=0.09, hspace=0.7)\n",
"\n",
"plot_param2d(plt.subplot(gs3a[0]), params.thetareg[isub], iregs=iregs)\n",
"plot_param2d(plt.subplot(gs3a[0]), params.thetareg[isub], iregs=iregs, labels=['R1', 'R2', 'R3'])\n",
"plot_param1d(plt.subplot(gs3a[1]), ds.thetasub[:,0], params.thetasub[:,0,:], \"G\", r\"Inferred $\\theta^s_1$\",\n",
" example=3)\n",
"\n",
"for i, (ireg, color, label) in enumerate(zip(iregs, colors, ['A','B','C'])):\n",
"for i, (ireg, color, label) in enumerate(zip(iregs, colors, ['R1','R2','R3'])):\n",
" plot_phaseplot(plt.subplot(gs3b[i]), model, sims.x[isample:isample+1,isub,ireg,:,-nt:],\n",
" treg=params.thetareg[isub,ireg,:,0], tsub=params.thetasub[isub,:,0],\n",
" color=color, label=label, xlabels=(i == 2), nquiver=50)\n",
Expand Down Expand Up @@ -488,7 +496,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down
38 changes: 23 additions & 15 deletions study/notebooks/Fig_PMFM.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"metadata": {},
"outputs": [],
"source": [
"colors = ['tab:blue', 'tab:red', 'tab:green']\n",
"colors = ['#006BA4', '#FF800E', '#595959']\n",
"\n",
"\n",
"def axbottomleft(ax):\n",
Expand All @@ -159,7 +159,7 @@
"def plot_sc(ax, cax, ds, isub):\n",
" plt.sca(ax)\n",
" plt.title(\"Structural conn.\")\n",
" im = plt.imshow(ds.w[isub], cmap='cividis')\n",
" im = plt.imshow(ds.w[isub], cmap='Greys')\n",
" plt.xticks([])\n",
" plt.yticks([])\n",
" plt.xlabel(\"Regions\")\n",
Expand Down Expand Up @@ -221,7 +221,7 @@
"metadata": {},
"outputs": [],
"source": [
"def plot_param2d(ax, pest, ptru=None, param_name=None, lim=None, iregs=None):\n",
"def plot_param2d(ax, pest, ptru=None, param_name=None, lim=None, iregs=None, labels=None):\n",
" plt.sca(ax) \n",
" \n",
" if lim is None:\n",
Expand Down Expand Up @@ -249,6 +249,14 @@
" color='k', lw=lw, zorder=zorder)\n",
" plt.plot([pest[i,0,0], pest[i,0,0]], [pest[i,1,0]-pest[i,1,1], pest[i,1,0]+pest[i,1,1]],\n",
" color='k', lw=lw, zorder=zorder)\n",
" \n",
" if labels is not None: \n",
" for ireg, label, col in zip(iregs, labels, colors):\n",
" ha = 'left' if pest[ireg,0,0] > 0 else 'right'\n",
" va = 'bottom' if pest[ireg,1,0] > 0 else 'top'\n",
" offset = (0.2 if ha=='left' else 0.2, 0.) \n",
" plt.text(pest[ireg,0,0]+offset[0], pest[ireg,1,0]+offset[1], label, color=col,\n",
" ha=ha, va=va, fontsize=7)\n",
" \n",
" plt.xlim(-2,2)\n",
" plt.ylim(-2,2)\n",
Expand Down Expand Up @@ -309,12 +317,12 @@
" plt.text(0.04, 0.96, label, ha='left', va='top', transform=ax.transAxes, color=color, fontsize=8,\n",
" bbox=dict(boxstyle='square', facecolor='white', alpha=0.85))\n",
" \n",
" for pos in ['bottom', 'top', 'right', 'left']:\n",
" ax.spines[pos].set_color(color)\n",
" ax.spines[pos].set_linewidth(1.5)\n",
" ax.tick_params(axis='both', colors=color)\n",
" ax.xaxis.label.set_color(color)\n",
" ax.yaxis.label.set_color(color) \n",
"# for pos in ['bottom', 'top', 'right', 'left']:\n",
"# ax.spines[pos].set_color(color)\n",
"# ax.spines[pos].set_linewidth(1.5)\n",
"# ax.tick_params(axis='both', colors=color)\n",
"# ax.xaxis.label.set_color(color)\n",
"# ax.yaxis.label.set_color(color) \n",
" \n",
" \n",
" \n",
Expand Down Expand Up @@ -391,7 +399,7 @@
" plot_obs_all(ax1, t, y, examples, title=\"Time series\")\n",
"\n",
" ax2 = plt.subplot(gs[1,0])\n",
" plot_obs_lines(ax2, t, y[examples], labels=['A', 'B', 'C'], offset=4)\n",
" plot_obs_lines(ax2, t, y[examples], labels=['R1', 'R2', 'R3'], offset=4)\n",
" plt.xlim(0,864)\n",
" \n",
" plt.plot([60, 180], [5,5], lw=2, color='k', clip_on=False)\n",
Expand All @@ -404,7 +412,7 @@
" plot_fc(ax3, cax3, y)\n",
"\n",
" ax4 = plt.subplot(gs[1,1])\n",
" plot_obs_lines(ax4, t, y[examples], labels=['A', 'B', 'C'], offset=4)\n",
" plot_obs_lines(ax4, t, y[examples], labels=['R1', 'R2', 'R3'], offset=4)\n",
" plt.xlim(tzoom)\n",
" \n",
" plt.plot([tzoom[0] + 10, tzoom[0] + 20], [5, 5], lw=2, color='k', clip_on=False)\n",
Expand All @@ -425,7 +433,7 @@
" \n",
" for i in range(nsub):\n",
" plt.plot([ptru[i], ptru[i]], [pest[i,0]-pest[i,1], pest[i,0]+pest[i,1]], color='k', lw=0.7, zorder=10)\n",
" plt.scatter(ptru[i], pest[i,0], fc=('0.5' if i == example else 'white'), ec='k', lw=0.4, s=15)\n",
" plt.scatter(ptru[i], pest[i,0], fc=('#ABABAB' if i == example else 'white'), ec='k', lw=0.4, s=15)\n",
" \n",
" plt.xlabel(xlabel, labelpad=2)\n",
" plt.ylabel(ylabel, labelpad=0)\n",
Expand Down Expand Up @@ -473,11 +481,11 @@
"gs3b = fig.add_gridspec(nrows=3, ncols=1, left=0.22, right=0.30, top=0.56, bottom=0.08, hspace=0.15)\n",
"gs3c = fig.add_gridspec(nrows=2, ncols=1, left=0.39, right=0.50, top=0.49, bottom=0.09, hspace=0.7)\n",
"\n",
"plot_param2d(plt.subplot(gs3a[0]), params.thetareg[isub], iregs=iregs)\n",
"plot_param2d(plt.subplot(gs3a[0]), params.thetareg[isub], iregs=iregs, labels=['R1', 'R2', 'R3'])\n",
"plot_param1d(plt.subplot(gs3a[1]), ds.thetasub[:,0], params.thetasub[:,0,:], \"G\", r\"Inferred $\\theta^s_1$\",\n",
" example=2)\n",
"\n",
"for i, (ireg, color, label) in enumerate(zip(iregs, colors, ['A','B','C'])):\n",
"for i, (ireg, color, label) in enumerate(zip(iregs, colors, ['R1','R2','R3'])):\n",
" plot_phaseplot(plt.subplot(gs3b[i]), model, sims.x[isample:isample+1,isub,ireg,:,-int(0.75*nt):-int(0.5*nt)],\n",
" treg=params.thetareg[isub,ireg,:,0], tsub=params.thetasub[isub,:,0],\n",
" color=color, label=label, xlabels=(i == 2), nquiver=100, u=u[i])\n",
Expand Down Expand Up @@ -563,7 +571,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down
9 changes: 4 additions & 5 deletions study/notebooks/Fig_QuantComparison.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@
" plt.ylim(top=1.05)\n",
"\n",
"\n",
"\n",
"examples_hopf = [(2, 43, 11,'tab:blue'), (2, 53, 11, 'tab:red'), (2, 61, 11, 'tab:green')]\n",
"examples_hopf = [(2, 43, 11,'#006BA4'), (2, 53, 11, '#FF800E'), (2, 61, 11, '#595959')]\n",
" \n",
"plt.figure(figsize=(1,1), dpi=200)\n",
"plot_featurefit(plt.gca(), resp.ds, resp.sims, resp.surr, np.mean, absdiff, \"Mean\", \"Difference\", \n",
Expand Down Expand Up @@ -603,7 +602,7 @@
"plot_paramfit_pmfm(axd, resp.ds, resp.params)\n",
"\n",
"# Feature fit: Hopf\n",
"ex = [(3, 24, 45, 'tab:blue'), (3, 37, 45, 'tab:red'), (3, 58, 45, 'tab:green')]\n",
"ex = [(3, 24, 45, '#006BA4'), (3, 37, 45, '#FF800E'), (3, 58, 45, '#595959')]\n",
"gsb = gs[0,1].subgridspec(1, 2, wspace=1.4)\n",
"axb1, axb2 = plt.subplot(gsb[0]), plt.subplot(gsb[1])\n",
"funss = get_smooth_spectrum_fun(1./(resh.ds.t[1] - resh.ds.t[0]), 3)\n",
Expand All @@ -612,7 +611,7 @@
"plot_featurefit(axb2, resh.ds, resh.sims, resh.surr, np.var, absdiff, \"Variance\", \"|Difference|\", examples=ex)\n",
"\n",
"# Feature fit: pMFM\n",
"ex = [(2, 43, 34,'tab:blue'), (2, 53, 34, 'tab:red'), (2, 61, 33, 'tab:green')]\n",
"ex = [(2, 43, 34,'#006BA4'), (2, 53, 34, '#FF800E'), (2, 61, 33, '#595959')]\n",
"gse = gs[1,1].subgridspec(1, 2, wspace=1.4)\n",
"axe1, axe2 = plt.subplot(gse[0]), plt.subplot(gse[1])\n",
"plot_featurefit(axe1, resp.ds, resp.sims, resp.surr, identity, wdist, \"p(y)\", \"Wasserstein dist.\", \n",
Expand Down Expand Up @@ -733,7 +732,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.8.13"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c111acc

Please sign in to comment.