Skip to content Skip to sidebar Skip to footer

Matplotlib Colorbar Scientific Notation Offset

When plotting a colorbar, the top label (I guess this would be called the offset) is mis-centred. This didn't use to happen, I have examples of old code where it was centred above

Solution 1:

Using your above code and matplotlib version 1.4.3 I get the following plot enter image description here

So this may be a version issue. One possible work around could be to use cb.ax.text()

# -*- coding: utf-8 -*-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.ax.text(-0.25, 1, r'$\times$10$^{-1}$', va='bottom', ha='left')

plt.show()

This way you have more control over the centring. The above code gives me the following plot enter image description here Note that I use an r at the start of the string so that $\times$ produces the correct symbol.

Post a Comment for "Matplotlib Colorbar Scientific Notation Offset"