Closed
Description
Bug summary
When creating a LogNorm imshow plot with more than 9 orders of magnitude of dynamic range the automatically generated colorbar from plt.colorbar() has no automatically generated tick marks or labels.
Code for reproduction
This generates a plot with colorbar tick labels
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import LogNorm
data = np.zeros((800, 800)) + 1
data[50, 51] = 1e9
print(np.log10(data.max()/data.min()))
image = plt.imshow(data, origin='lower', interpolation='nearest', norm=LogNorm())
plt.colorbar(image)
plt.savefig('labels.png')
While this script generates a plot with no colorbar tick labels:
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import LogNorm
data = np.zeros((800, 800)) + 1
data[50, 51] = 2e9
print(np.log10(data.max()/data.min()))
image = plt.imshow(data, origin='lower', interpolation='nearest', norm=LogNorm())
plt.colorbar(image)
plt.savefig('no-labels.png')
Expected outcome
I would expect the second plot to also have colorbar tick labels.
Matplotlib version
- Operating system: Mac OS High Sierra
- Matplotlib version: 2.1.1 (installed via pip)
- Matplotlib backend (
print(matplotlib.get_backend())
): MacOSX - Python version: 3.6
ax3l