|
813 | 813 | " aperture.plot(color='white', alpha=0.7, axes=ax1)\n", |
814 | 814 | "\n", |
815 | 815 | "# Define the colorbar\n", |
816 | | - "cbar = plt.colorbar(fitsplot, fraction=0.046, pad=0.04, ticks=LogLocator(subs=range(10)))\n", |
817 | | - "labels = ['$10^{-4}$'] + [''] * 8 + ['$10^{-3}$'] + [''] * 8 + ['$10^{-2}$']\n", |
818 | | - "cbar.ax.set_yticklabels(labels)\n", |
| 816 | + "cbar = plt.colorbar(fitsplot, fraction=0.046, pad=0.04, ticks=LogLocator())\n", |
| 817 | + "\n", |
| 818 | + "def format_colorbar(bar):\n", |
| 819 | + " # Add minor tickmarks\n", |
| 820 | + " bar.ax.yaxis.set_minor_locator(LogLocator(subs=range(1, 10)))\n", |
| 821 | + "\n", |
| 822 | + " # Force the labels to be displayed as powers of ten and only at exact powers of ten\n", |
| 823 | + " bar.ax.set_yticks([1e-4, 1e-3, 1e-2])\n", |
| 824 | + " labels = [f'$10^{{{pow:.0f}}}$' for pow in np.log10(bar.ax.get_yticks())]\n", |
| 825 | + " bar.ax.set_yticklabels(labels)\n", |
| 826 | + "\n", |
| 827 | + "format_colorbar(cbar)\n", |
819 | 828 | "\n", |
820 | 829 | "# Define labels\n", |
821 | 830 | "cbar.set_label(r'Flux Count Rate ({})'.format(xdf_image.unit.to_string('latex')), \n", |
|
0 commit comments