Hi,

I hope someone can answer this colorbar related question.


I have a plot, to which I am drawing a colorbar. The standard colorbar ranges from the values -1 (blue) over 0 (green) to e.g. 1(red). So far so good.
But now I want to change the colorbar that it shows only the colors between 0 and 1. What I mean is: the colorbar should start at value 0 (with green) and go to 1(red), and leave the original plot unchanged.
I ad some example code below to make it more clear. In the example plot created, only the values between 0 and 1 are interesting and should be shown in the colorbar, but not -1 (blue). But I want  the original plot unchanged!

If anyone has an idea that would be great.

Cheers 
  Alex


 
import numpy as np
import matplotlib
import pylab as py


f = py.figure()
# create toy image
im = -np.ones((100,100))
for x in range(20,80):
    for y in range(20,80):
        im[x,y] = random.random()


# create imshow subplot
ax = f.add_subplot(111)
result = ax.imshow(im)


# Create the colorbar
axc, kw = matplotlib.colorbar.make_axes(ax)
cb = matplotlib.colorbar.Colorbar(axc, result)

# Set the colorbar
result.colorbar = cb

py.show()