Claas Teichmann wrote:
Hi David and Eric,
one year ago, you discussed a discretazation of the colorbar with
imshow() in matplotlib-users. The topic was "DIscretization of
colorbar". Did you succeed in using a discrete colorbar?
Yes, I completely rewrote the colorbar code, and it is now quite flexible.
I put a request to the mailinglist with the topic "Wrong
colorbar-ticks in imshow-colorbar with 10 colors". Maybe one of you
already got the answer?Many greetings!
Claas
Assuming you have a reasonably recent version of mpl, you can modify your colorbar call this way:
colorbar(ticks=linspace(im.norm.vmin, im.norm.vmax, 11))
(This is for your example with a 10-entry colormap.)
Because of a default parameter that is not exposed, it will label only every second color boundary in the example from your earlier message. To make it label every boundary, you could use
from matplotlib import ticker
ticks = linspace(im.norm.vmin, im.norm.vmax, 11)
tickmaker = ticker.FixedLocator(ticks, nbins=20)
# make nbins >= number of ticks
colorbar(ticks=tickmaker)
Eric