diff --git a/figures/Fig2_Theory_vs_Reconstruction.ipynb b/figures/Fig2_Theory_vs_Reconstruction.ipynb index 03095ba..07df386 100644 --- a/figures/Fig2_Theory_vs_Reconstruction.ipynb +++ b/figures/Fig2_Theory_vs_Reconstruction.ipynb @@ -41,6 +41,9 @@ "mpl.rcParams['pdf.fonttype'] = 42\n", "mpl.rcParams['ps.fonttype'] = 42\n", "\n", + "colornames = ['#646464', '#666666', '#6a6a6a', '#6f6f6f', '#737373', '#787878', '#7d7d7d', '#828282', '#878787', '#8d8d8d', '#929292', '#989898', '#9e9e9e', '#a4a4a4', '#aaaaaa', '#b0b0b0', '#b6b6b6', '#bcbcbc', '#c2c2c2', '#c9c9c9', '#cfcfcf', '#d6d6d6', '#dcdcdc', '#e3e3e3', '#eaeaea', '#efefee', '#efeee5', '#efeddc', '#efecd3', '#eeebca', '#eeeac0', '#eee9b7', '#eee8ad', '#ede7a4', '#ede69a', '#ede590', '#ede487', '#ece37d', '#ece273', '#ece069', '#ecdf5f', '#ebde55', '#ebdd4b', '#ebdc41', '#ebdb37', '#ebd333', '#ebc933', '#ecbe32', '#ecb432', '#eda931', '#ee9e31', '#ee9330', '#ef8830', '#ef7d2f', '#f0722f', '#f0672e', '#f15c2e', '#f2512d', '#f2462d', '#f33b2c', '#f3302c', '#f4252b', '#f4192b', '#ef182f', '#e81834', '#e21939', '#db1a3e', '#d51a43', '#ce1b48', '#c71b4d', '#c11c52', '#ba1c58', '#b31d5d', '#ac1d62', '#a61e67', '#9f1e6c', '#981f72', '#911f77', '#8a207c', '#842182']\n", + "custom_cmap = mpl.colors.LinearSegmentedColormap.from_list('custom', colornames, N=256)\n", + "\n", "# Create plot folder if needed\n", "if not os.path.exists('../results/figures'):\n", " os.mkdir('../results/figures')" @@ -111,7 +114,7 @@ " kyy = np.reshape(kyy, (nkx * nky,))\n", " Ek_scaled = np.reshape(intFunc(np.column_stack((kxx, kyy))), (nkx, nky))\n", " \n", - " axs[i,0].imshow(Ek_scaled.T*msk, cmap='Spectral_r',\n", + " axs[i,0].imshow(Ek_scaled.T*msk, cmap=custom_cmap,\n", " extent=[kx[0]+kxshift, kx[-1]+kxshift, ky[0], ky[-1]])\n", " axs[i,0].spines['right'].set_color('none')\n", " axs[i,0].spines['top'].set_color('none')\n", @@ -130,7 +133,7 @@ " axs[i,0].plot(kpks[:,1]-0.02, kpks[:,0], '--k', lw=1, dashes=[5, 4])\n", " \n", " # Draw the reconstruction side\n", - " axs[i,1].imshow(recbands[ind,...]*msk, cmap='Spectral_r', extent=[kx[0]+kxshift, kx[-1]+kxshift, ky[0], ky[-1]])\n", + " axs[i,1].imshow(recbands[ind,...]*msk, cmap=custom_cmap, extent=[kx[0]+kxshift, kx[-1]+kxshift, ky[0], ky[-1]])\n", " axs[i,1].spines['right'].set_color('none')\n", " axs[i,1].spines['top'].set_color('none')\n", " axs[i,1].tick_params(axis='both', length=8, width=2, labelsize=28)\n", @@ -174,7 +177,7 @@ " kyy = np.reshape(kyy, (nkx * nky,))\n", " Ek_scaled = np.reshape(intFunc(np.column_stack((kxx, kyy))), (nkx, nky))\n", " \n", - " axs[i,0].imshow(Ek_scaled.T*msk, cmap='Spectral_r',\n", + " axs[i,0].imshow(Ek_scaled.T*msk, cmap=custom_cmap,\n", " extent=[kx[0]+0.05, kx[-1]+0.05, ky[0], ky[-1]])\n", " axs[i,0].spines['right'].set_color('none')\n", " axs[i,0].spines['top'].set_color('none')\n", @@ -193,7 +196,7 @@ " axs[i,0].plot(kpks[:,1]-0.02, kpks[:,0], '--k', lw=1, dashes=[5, 4])\n", " \n", " # Draw the reconstruction side\n", - " axs[i,1].imshow(recbands[ind,...]*msk, cmap='Spectral_r', extent=[kx[0]+kxshift, kx[-1]+kxshift, ky[0], ky[-1]])\n", + " axs[i,1].imshow(recbands[ind,...]*msk, cmap=custom_cmap, extent=[kx[0]+kxshift, kx[-1]+kxshift, ky[0], ky[-1]])\n", " axs[i,1].spines['right'].set_color('none')\n", " axs[i,1].spines['top'].set_color('none')\n", " axs[i,1].tick_params(axis='both', length=8, width=2, labelsize=28)\n", diff --git a/figures/Fig3_HexagonalZernike.ipynb b/figures/Fig3_HexagonalZernike.ipynb index 6472b46..d66b970 100644 --- a/figures/Fig3_HexagonalZernike.ipynb +++ b/figures/Fig3_HexagonalZernike.ipynb @@ -42,6 +42,9 @@ "mpl.rcParams['pdf.fonttype'] = 42\n", "mpl.rcParams['ps.fonttype'] = 42\n", "\n", + "colornames = ['#646464', '#666666', '#6a6a6a', '#6f6f6f', '#737373', '#787878', '#7d7d7d', '#828282', '#878787', '#8d8d8d', '#929292', '#989898', '#9e9e9e', '#a4a4a4', '#aaaaaa', '#b0b0b0', '#b6b6b6', '#bcbcbc', '#c2c2c2', '#c9c9c9', '#cfcfcf', '#d6d6d6', '#dcdcdc', '#e3e3e3', '#eaeaea', '#efefee', '#efeee5', '#efeddc', '#efecd3', '#eeebca', '#eeeac0', '#eee9b7', '#eee8ad', '#ede7a4', '#ede69a', '#ede590', '#ede487', '#ece37d', '#ece273', '#ece069', '#ecdf5f', '#ebde55', '#ebdd4b', '#ebdc41', '#ebdb37', '#ebd333', '#ebc933', '#ecbe32', '#ecb432', '#eda931', '#ee9e31', '#ee9330', '#ef8830', '#ef7d2f', '#f0722f', '#f0672e', '#f15c2e', '#f2512d', '#f2462d', '#f33b2c', '#f3302c', '#f4252b', '#f4192b', '#ef182f', '#e81834', '#e21939', '#db1a3e', '#d51a43', '#ce1b48', '#c71b4d', '#c11c52', '#ba1c58', '#b31d5d', '#ac1d62', '#a61e67', '#9f1e6c', '#981f72', '#911f77', '#8a207c', '#842182']\n", + "custom_cmap = mpl.colors.LinearSegmentedColormap.from_list('custom', colornames, N=256)\n", + "\n", "# Create plot folder if needed\n", "if not os.path.exists('../results/figures'):\n", " os.mkdir('../results/figures')" @@ -77,7 +80,7 @@ "ff, axs = plt.subplots(5, 1, figsize=(3, 10))\n", "\n", "for ind, ibs in enumerate([3, 10, 27, 41, 89]):\n", - " im = axs[ind].imshow(basis[ibs,...]*bmask[...], cmap='Spectral_r', vmin=-1.8, vmax=1.8)\n", + " im = axs[ind].imshow(basis[ibs,...]*bmask[...], cmap=custom_cmap, vmin=-1.8, vmax=1.8)\n", " axs[ind].axis('off')\n", " axs[ind].text(5, 5, str(ind+1), fontsize=15, fontname=\"Arial\")\n", "\n", diff --git a/figures/Fig5_K_and_Mprime.ipynb b/figures/Fig5_K_and_Mprime.ipynb index f63b64f..4cf565d 100644 --- a/figures/Fig5_K_and_Mprime.ipynb +++ b/figures/Fig5_K_and_Mprime.ipynb @@ -37,6 +37,9 @@ "mpl.rcParams['pdf.fonttype'] = 42\n", "mpl.rcParams['ps.fonttype'] = 42\n", "\n", + "colornames = ['#646464', '#666666', '#6a6a6a', '#6f6f6f', '#737373', '#787878', '#7d7d7d', '#828282', '#878787', '#8d8d8d', '#929292', '#989898', '#9e9e9e', '#a4a4a4', '#aaaaaa', '#b0b0b0', '#b6b6b6', '#bcbcbc', '#c2c2c2', '#c9c9c9', '#cfcfcf', '#d6d6d6', '#dcdcdc', '#e3e3e3', '#eaeaea', '#efefee', '#efeee5', '#efeddc', '#efecd3', '#eeebca', '#eeeac0', '#eee9b7', '#eee8ad', '#ede7a4', '#ede69a', '#ede590', '#ede487', '#ece37d', '#ece273', '#ece069', '#ecdf5f', '#ebde55', '#ebdd4b', '#ebdc41', '#ebdb37', '#ebd333', '#ebc933', '#ecbe32', '#ecb432', '#eda931', '#ee9e31', '#ee9330', '#ef8830', '#ef7d2f', '#f0722f', '#f0672e', '#f15c2e', '#f2512d', '#f2462d', '#f33b2c', '#f3302c', '#f4252b', '#f4192b', '#ef182f', '#e81834', '#e21939', '#db1a3e', '#d51a43', '#ce1b48', '#c71b4d', '#c11c52', '#ba1c58', '#b31d5d', '#ac1d62', '#a61e67', '#9f1e6c', '#981f72', '#911f77', '#8a207c', '#842182']\n", + "custom_cmap = mpl.colors.LinearSegmentedColormap.from_list('custom', colornames, N=256)\n", + "\n", "# Create plot folder if needed\n", "if not os.path.exists('../results/figures'):\n", " os.mkdir('../results/figures')" @@ -102,18 +105,18 @@ " ax[1, i].set_yticks([])\n", " ax[1, i].set_xlabel('$k_x$ ($\\mathrm{\\AA}^{-1}$)', fontsize=15)\n", " \n", - "cs00 = ax[0, 0].contourf(kxx, kyy, mpatch[0,...], 20, cmap='Spectral_r', vmin=-1.6, vmax=-1)\n", + "cs00 = ax[0, 0].contourf(kxx, kyy, mpatch[0,...], 20, cmap=custom_cmap, vmin=-1.6, vmax=-1)\n", "ax[0, 0].contour(cs00, colors='k', linestyles='-', linewidths=0.5)\n", "ax[0, 0].text(0.65, 0.9, 'Band #1', fontsize=15, transform=ax[0,0].transAxes)\n", "\n", - "cs10 = ax[1, 0].contourf(kxx, kyy, mpatch[1,:,:], 20, cmap='Spectral_r', vmin=-1.95, vmax=-1.4)\n", + "cs10 = ax[1, 0].contourf(kxx, kyy, mpatch[1,:,:], 20, cmap=custom_cmap, vmin=-1.95, vmax=-1.4)\n", "ax[1, 0].contour(cs10, colors='k', linestyles='-', linewidths=0.5)\n", "ax[1, 0].text(0.65, 0.9, 'Band #2', fontsize=15, transform=ax[1,0].transAxes)\n", " \n", - "cs01 = ax[0, 1].contourf(kxx, kyy, bands[0,...], 20, cmap='Spectral_r', vmin=-1.6, vmax=-1)\n", + "cs01 = ax[0, 1].contourf(kxx, kyy, bands[0,...], 20, cmap=custom_cmap, vmin=-1.6, vmax=-1)\n", "ax[0, 1].contour(cs01, colors='k', linestyles='-', linewidths=0.5)\n", "\n", - "cs11 = ax[1, 1].contourf(kxx, kyy, bands[1,...], 20, cmap='Spectral_r', vmin=-1.95, vmax=-1.4)\n", + "cs11 = ax[1, 1].contourf(kxx, kyy, bands[1,...], 20, cmap=custom_cmap, vmin=-1.95, vmax=-1.4)\n", "ax[1, 1].contour(cs11, colors='k', linestyles='-', linewidths=0.5)\n", "\n", "plt.subplots_adjust(hspace=0.08, wspace=0.08)\n", @@ -180,24 +183,24 @@ " ax[1, i].set_yticks([])\n", " ax[1, i].set_xlabel('$k_x$ ($\\mathrm{\\AA}^{-1}$)', fontsize=15)\n", " \n", - "cs00 = ax[0, 0].contourf(kxx, kyy, rcfb['bands'][0,ofs+1:-ofs+1,ofs:-ofs], 23, cmap='Spectral_r', vmax=-0.7, vmin=-1.2+minsft)\n", + "cs00 = ax[0, 0].contourf(kxx, kyy, rcfb['bands'][0,ofs+1:-ofs+1,ofs:-ofs], 23, cmap=custom_cmap, vmax=-0.7, vmin=-1.2+minsft)\n", "ax[0, 0].contour(cs00, colors='k', linestyles='-', linewidths=0.5)\n", "ax[0, 0].text(0.65, 0.9, 'Band #1', fontsize=15, transform=ax[0,0].transAxes)\n", "\n", - "cs10 = ax[1, 0].contourf(kxx, kyy, rcfb['bands'][1,ofs+1:-ofs+1,ofs:-ofs], 23, cmap='Spectral_r', vmax=-1.15, vmin=-1.55+minsft)\n", + "cs10 = ax[1, 0].contourf(kxx, kyy, rcfb['bands'][1,ofs+1:-ofs+1,ofs:-ofs], 23, cmap=custom_cmap, vmax=-1.15, vmin=-1.55+minsft)\n", "ax[1, 0].contour(cs10, colors='k', linestyles='-', linewidths=0.5)\n", "ax[1, 0].text(0.65, 0.9, 'Band #2', fontsize=15, transform=ax[1,0].transAxes)\n", " \n", - "cs01 = ax[0, 1].contourf(kxx, kyy, rfb['bands'][0,ofs+1:-ofs+1,ofs:-ofs], 23, cmap='Spectral_r', vmax=-0.7, vmin=-1.2+minsft)\n", + "cs01 = ax[0, 1].contourf(kxx, kyy, rfb['bands'][0,ofs+1:-ofs+1,ofs:-ofs], 23, cmap=custom_cmap, vmax=-0.7, vmin=-1.2+minsft)\n", "ax[0, 1].contour(cs01, colors='k', linestyles='-', linewidths=0.5)\n", "\n", - "cs11 = ax[1, 1].contourf(kxx, kyy, rfb['bands'][1,ofs+1:-ofs+1,ofs:-ofs], 23, cmap='Spectral_r', vmax=-1.15, vmin=-1.55+minsft)\n", + "cs11 = ax[1, 1].contourf(kxx, kyy, rfb['bands'][1,ofs+1:-ofs+1,ofs:-ofs], 23, cmap=custom_cmap, vmax=-1.15, vmin=-1.55+minsft)\n", "ax[1, 1].contour(cs11, colors='k', linestyles='-', linewidths=0.5)\n", "\n", - "cs02 = ax[0, 2].contourf(kxx, kyy, fitbs['b1'], 23, cmap='Spectral_r', vmax=-0.7, vmin=-1.2+minsft)\n", + "cs02 = ax[0, 2].contourf(kxx, kyy, fitbs['b1'], 23, cmap=custom_cmap, vmax=-0.7, vmin=-1.2+minsft)\n", "ax[0, 2].contour(cs02, colors='k', linestyles='-', linewidths=0.5)\n", "\n", - "cs12 = ax[1, 2].contourf(kxx, kyy, fitbs['b2'], 23, cmap='Spectral_r', vmax=-1.15, vmin=-1.55+minsft)\n", + "cs12 = ax[1, 2].contourf(kxx, kyy, fitbs['b2'], 23, cmap=custom_cmap, vmax=-1.15, vmin=-1.55+minsft)\n", "ax[1, 2].contour(cs12, colors='k', linestyles='-', linewidths=0.5)\n", "\n", "cs03 = ax[0, 3].contourf(kxx, kyy, 1e3*(fitbs['b1'] - rfb['bands'][0,ofs+1:-ofs+1,ofs:-ofs]), 23, cmap='RdBu_r', vmax=12, vmin=-12)\n", diff --git a/figures/SFig4_Hyperparameter_tuning.ipynb b/figures/SFig4_Hyperparameter_tuning.ipynb index 3ce8117..a3435e8 100644 --- a/figures/SFig4_Hyperparameter_tuning.ipynb +++ b/figures/SFig4_Hyperparameter_tuning.ipynb @@ -42,6 +42,9 @@ "mpl.rcParams['pdf.fonttype'] = 42\n", "mpl.rcParams['ps.fonttype'] = 42\n", "\n", + "colornames = ['#646464', '#666666', '#6a6a6a', '#6f6f6f', '#737373', '#787878', '#7d7d7d', '#828282', '#878787', '#8d8d8d', '#929292', '#989898', '#9e9e9e', '#a4a4a4', '#aaaaaa', '#b0b0b0', '#b6b6b6', '#bcbcbc', '#c2c2c2', '#c9c9c9', '#cfcfcf', '#d6d6d6', '#dcdcdc', '#e3e3e3', '#eaeaea', '#efefee', '#efeee5', '#efeddc', '#efecd3', '#eeebca', '#eeeac0', '#eee9b7', '#eee8ad', '#ede7a4', '#ede69a', '#ede590', '#ede487', '#ece37d', '#ece273', '#ece069', '#ecdf5f', '#ebde55', '#ebdd4b', '#ebdc41', '#ebdb37', '#ebd333', '#ebc933', '#ecbe32', '#ecb432', '#eda931', '#ee9e31', '#ee9330', '#ef8830', '#ef7d2f', '#f0722f', '#f0672e', '#f15c2e', '#f2512d', '#f2462d', '#f33b2c', '#f3302c', '#f4252b', '#f4192b', '#ef182f', '#e81834', '#e21939', '#db1a3e', '#d51a43', '#ce1b48', '#c71b4d', '#c11c52', '#ba1c58', '#b31d5d', '#ac1d62', '#a61e67', '#9f1e6c', '#981f72', '#911f77', '#8a207c', '#842182']\n", + "custom_cmap = mpl.colors.LinearSegmentedColormap.from_list('custom', colornames, N=256)\n", + "\n", "# Create plot folder if needed\n", "if not os.path.exists('../results/figures'):\n", " os.mkdir('../results/figures')" @@ -109,7 +112,7 @@ "source": [ "# Plot a grid of reconstructed bands\n", "ims, axs = vis.sliceview3d(smaband*msk[None,...], axis=0, ncol=7, vmin=-1, vmax=0,\n", - " colormap='Spectral_r', axisreturn='nested', numbered=False, figsize=(20, 20*5/7),\n", + " colormap=custom_cmap, axisreturn='nested', numbered=False, figsize=(20, 20*5/7),\n", " imkwds={'extent':[kx[0]+0.05, kx[-1]+0.05, ky[0]-0.02, ky[-1]-0.02]});\n", "\n", "# Annotate the plot-frames of good reconstructions\n", @@ -165,7 +168,7 @@ "fig = plt.figure(figsize=(8, 3))\n", "ax = fig.add_axes([0.05, 0.80, 0.04, 0.5])\n", "norm = mpl.colors.Normalize(vmin=-1, vmax=0)\n", - "cb = mpl.colorbar.ColorbarBase(ax, cmap=plt.get_cmap('Spectral_r'),\n", + "cb = mpl.colorbar.ColorbarBase(ax, cmap=custom_cmap,\n", " norm=norm, ticks=[-1, 0],\n", " orientation='vertical')\n", "# cb.ax.set_yticks([-1, 0])\n",