It looks like you passed the wrong object to the colorbar constructor.
This should work:
The above snippet is based on the code in your answer; here's a complete, standalone example:
import numpy as NP from matplotlib import pyplot as PLT A = NP.random.random_integers(0, 10, 100).reshape(10, 10) fig = PLT.figure() ax1 = fig.add_subplot(111) cax = ax1.imshow(A, interpolation="nearest")
As I said in the comment above, I would choose a cleaner namespace that you have, for example, there are modules with the same name in NumPy and Matplotlib.
In particular, I would use this import statement to import the Matplotlib "core" graphic functions:
from matplotlib import pyplot as PLT
Of course, this does not give the full matplotlib namespace (which really is the point of this import statement), although usually this is all you need.
source share