I would call it a limitation of the present simple design, not a bug or a feature.
I would like to know if that it is normal to have the colorbar bigger than the image when used with imshow. By bigger I means when the image is plotting with a label, the colorbar doesn't stop at the image but use the space where is the label.
mat = numarray.arange(100,shape=(10,10))
The present colorbar uses a very simple method to set its size and position; I think it is essentially the same as what the Matlab colorbar does. If that doesn't yield what you want, then for now you need to manually adjust the size and shape of the axes object returned by the colorbar command, or make your own axes beforehand and give that as an argument to the colorbar method of the figure object.
As part of a reworking of the colorbar, I may be able to improve the automatic positioning and/or make manual adjustments easier. It is likely to be a while before I get to that point, however, and the need for at least occasional manual adjustment will never go away.
Another question. Is it possible to gave a xlabel (or ylabel) to the colorbar and the image independantly? I tried to use xlabel (ylabel) after the colorbar but that does nothing.
Yes, but you need to grab the axes object returned by colorbar(); otherwise pylab has no way of knowing which axes you are trying to label.
See contourf_demo.py for an example. A relevant fragment is this:
CS2 = contour(X, Y, Z, CS.levels,
colors = 'r',
xlabel('word length anomaly')
ylabel('sentence length anomaly')
# Make a colorbar for the ContourSet returned by the contourf call.
ax_cbar = colorbar(CS, tickfmt='%1.2f')
If you want to change the size of the colorbar, shrinking it in the vertical, for example, you could do something like:
l,b,w,h = ax_cbar.get_position()
bb = b + 0.1 * h
hh = 0.8 * h
(If you are doing this interactively in ipython, you may need a call to draw_if_interactive() to force a redraw.)
(There is code in svn to make this sort of thing easier, but it is incomplete and not yet ready for general use.)