I am trying to make a contour plot with the contour levels scaled by the log of the values. However, the colorbar does not show enough values next to the colors. Here is a simple example.
import numpy as N
import matplotlib as M
import matplotlib.pyplot as PLT
# Set up a simple function to plot
values = N.empty((10,10))
for xi in range(10):
for yi in range(10):
values[xi,yi] = N.exp(xi*yi/10. - 1)
levels = N.logspace(-1, 4, 10)
log_norm = M.colors.LogNorm()
# Currently not used - linear scaling
linear_norm = M.colors.Normalize()
# Plot the function using the indices as the x and y axes
PLT.contourf(values, norm=log_norm, levels=levels)
PLT.colorbar()
If you switch log_norm for linear_norm in the contourf call, you’ll see that the colorbar does have values. Of course, using linear_norm means the colors are scaled linearly and the contours are not well distributed for this function.
I’m using python 2.7.2, enthought edition which comes with matplotlib, on Mac OS 10.7.
Add a format to the call to
PLT.colorbar: