How would one get a colorbar() with a matshow plot? That
> is without altering the matshow code in pylab.,py.
A good question. The naive answer is: add the gci._current line to
the matshow code below the imshow line
im = ax.imshow(*args,**kw)
gci._current = im
and then do
In : matshow(rand(12,12))
In : colorbar()
The problem, of course, is that colorbar resizes the current axes,
which defeats the purpose of matshow.
What one needs is a colorbar kwarg to the matshow function that makes
extra room for the colorbar and still preserves the aspect ratio.
This would require some arithmetic and extra work. Any takers?
Perry and I have been discussing some ideas to make this kind of
layout easier. The problem is that the figure size is picked first,
and the axes are fractions of that. In addition to the current
functionality, it would be nice to have a figure container that
resized itself, and axes that were in physical sizes. Eg, something
fig = FigureDynamic()
ax = AxesSized(5,5) # inches
cax = AxesSized(.5,5) # inches
X = rand(12,12)
ax.imshow(X) # aspect ratio is correct since axwidth=axheight
When you add the axes, the figure window would resize itself to
accommodate them, which is the inverse of what happens currently --
the axes physical dimensions resize themselves according to the figure
physical size. I think both approaches are useful.