matplotlibformattingmultiple-axes

How can I reformat axis labels to scientific notation in matplotlib?


I've produced this graph enter image description here using the code I've pasted here.

How can I reformat the right-most y labels to be the same notation as the left-most y axis? The relevant part of my code is:

ax1.set_ylabel('Flux sensitivity, $\Delta S$ [Jy]')
ax1.set_xlabel('Integration time [s]')
ax1.set_xscale('log')
ax1.set_yscale('log')
ax1.grid(True)

ax2 = ax1.twiny()
hours = [0.03, 0.28, 2.78, 27.8, 278]
seconds = [1e2, 1e3, 1e4, 1e5, 1e6]
ax2.set_xscale('log')
ax2.set_xticks(seconds)
ax2.set_xticklabels(hours, rotation = 0)
ax2.set_xlabel('Integration time [hours]')
ax2.set_xlim(ax1.get_xlim())

ax3 = ax1.twinx()
WmHz   = [1e-30, 1e-31, 1e-32, 1e-33]
jansky = [1e-4, 1e-5, 1e-6, 1e-7]
ax3.set_yscale('log')
ax3.set_yticks(jansky)
ax3.set_yticklabels(WmHz, rotation = 0)
ax3.set_ylabel(r'Flux sensitivity [W m$^{-2}$ Hz$^{-1}$]')
ax3.set_ylim(ax1.get_xlim())

Solution

  • SOLVED: I formatted the WmHz list as

    WmHz = [r'$10^{-30}$', r'$10^{-31}$', r'$10^{-32}$', r'$10^{-33}$']