Force scientific style for colorbar baseemap shortcuts

String formatting can be used to indicate scientific notation for matplotlib.basemap colorbar labels:

cb = m.colorbar(cs, ax=ax1, format='%.4e')

But then each label is scientifically indicated by a base.

If the numbers are large enough, colobar automatically reduces them to scientific notation by placing the base (i.e. x10^n) at the top of the color bar, leaving only the numbers of the coefficients as labels.

You can do this with a standard axis with the following:

ax.ticklabel_format(style='sci', axis='y', scilimits=(0,0))

Is there an equivalent method for matplotlib.basemap colorbars, or maybe a standard matplotlib color template?

+4
source share
1 answer

, , colorbar formatter, colorbar.update_ticks().

import numpy as np
import matplotlib.pyplot as plt

z = np.random.random((10,10))

fig, ax = plt.subplots()
im = ax.imshow(z)
cb = fig.colorbar(im)

cb.formatter.set_powerlimits((0, 0))
cb.update_ticks()

plt.show()

enter image description here

, . (colorbar.ax) 0 1. ( colorbar.ax.yaxis.formatter .) colorbar.locator colorbar.formatter , . , tickbar/ticklables colorbar, colorbar.update_ticks() , . colorbar , , , , , .

+10

All Articles