From: Eric Firing <efiring@ha...>  20060116 00:43:12

Michael, You are right, I left the norm kwarg out of the contour function, and colorbar uses contourf. I think I have it fixed now, and I can commit to CVS shortly, but I should do a little more checking first. I will send you a png file offline, and you can tell me if it is giving the result you expect. Eric Michael Fitzgerald wrote: > Hello all, > > I've stumbled onto a bug in colorbar() when displaying an image with a > nonlinear normalization (using a recent CVS version of mpl). If one > subclasses matplotlib.colors.normalize and uses a nonlinear function in the > __call__() method, then colorbar() will mismatch colors and data values in > the colorbar. > > Some code illustrating a test case is attached. Here, I use the sqrt() > function to normalize some data in the domain (0, 10) to the range (0, 1) > [f(x)=sqrt(x/10)]. I display an image which consists of a linear ramp, each > value given by the abcissa. The normalization function y=f(x) is overplotted > for reference. imshow() applies the normalization before looking up the > colormap value, as expected (colors are bunched to the left). However, note > the values in the colorbar annotation do not correspond to the data values! > For example, prenormalization data value 4 (xaxis) is correctly colored as > yellow, however the color bar erroneously lists that value as cyan (which is > the color where y=4/10=.4). > > The error is that colorbar() assumes linearity over the normalization domain. > Ultimately, I think I'd like a choice as to whether to stretch colors in the > colorbar with a linear sampling of the data domain, or keep the color > sequence linear and invert the normalization step to determine the tick > values. Has anyone encountered and/or coded a solution for this? > > Thanks, > Mike > 