-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Milestone
Description
Matplotlib version 1.5.1, Python version 2.7.6 (Enthought Canopy) and OSX
As detailed in this stack overflow post, you have to explicitly specify the minor tick locations on a log scaled color bar. It would be nice if matplotlib would do this for you, instead of having to call minorticks = p.norm(np.hstack([np.arange(2, 10, 1)/10.0, np.arange(2, 10, 1)/1.0])
in the code below
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
x = np.linspace(1,10,10)
y = np.linspace(1,10,10)
X, Y = np.meshgrid(x,y)
Z = np.abs(np.cos(X**2 - Y**2) * X**2 * Y)
f, ax = plt.subplots()
p = plt.pcolormesh(X, Y, Z, norm=LogNorm(), vmin=1e-2, vmax=1e2)
cb = plt.colorbar(p, ax=ax, orientation='horizontal', aspect=10)
# We need to nomalize the tick locations so that they're in the range from 0-1...
minorticks = p.norm(np.hstack([np.arange(2, 10, 1)/10.0, np.arange(2, 10, 1)/1.0]))
cb.ax.xaxis.set_ticks(minorticks, minor=True)
plt.show()