I'm having troubble creating a filled contour plot that has both a logarithmic color scaling as well as having more colors than whatever is chosen by default. I'm basically trying to follow this example but while adding more colors, but whenever I add more colors, the numbers on the colorbar disappear (ticks are still there).
My basic code is
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import ticker
from matplotlib.colors import LogNorm
z = np.random.lognormal(mean=10, sigma=3, size=(10,10))
fig, ax = plt.subplots()
levels=np.logspace(np.log10(np.min(z)),np.log10(np.max(z)),100)
plot = ax.contourf(z, levels, norm=LogNorm())
cbar = fig.colorbar(plot)
plt.show()
I've also tried using
plot = ax.contourf(z, levels, locator=ticker.LogLocator())
but I get the same result. Tick marks are there but there aren't any numbers on the color bar:
Also, following the Matplotlib documentation, it seems like
plot = ax.contourf(z, 100, norm=LogNorm())
should get me 101 logarithmically-spaced color levels but it just defaults to the normal number.