So far I have tried this... colourmap = cm.get_cmap("Greys_r") colourmap = colourmap._segmentdata
# exclude 0, 0, 0...i.e. black from dictionary bvals = colourmap['blue'][1:] gvals = colourmap['green'][1:] rvals = colourmap['red'][1:] colourmap = { "blue":bvals, "green":gvals, "red":rvals } colourmap = cm.set_cmap(colourmap) But it doesn't seem to like the set_cmap command colourmap = cm.set_cmap(colourmap) AttributeError: 'module' object has no attribute 'set_cmap' So I guess that isn't the way, nor I suspect is that all that elegant. Martin mdekauwe wrote: > > Hi, > > I am setting a colourbar where I explictly set the tick intervals. However > I would like to exclude the colour black from this colourbar. The reason > for this is I would like to overplot some contour lines in black, so would > like to make them stand out. > > An example...where I would like to exclude black as the bottom colour of > the colourbar, i.e. use the next level of gray. > > import numpy as np > from mpl_toolkits.basemap import Basemap > import matplotlib.pyplot as plt > import matplotlib.colors as colors > import matplotlib as mpl > > data = np.random.randint(0,50,100*100).reshape(100, 100) > m = Basemap(llcrnrlon=1.5, llcrnrlat=10.5, urcrnrlon=3.5, urcrnrlat=13.5, > resolution='c', projection='cyl') > fig = plt.figure(figsize=(8, 6)) > ax = fig.add_axes([0.1, 0.1, 0.6, 0.7]) > m.ax = ax > > colourmap = plt.cm.Greys_r > ticks = [0, 10, 20, 30, 40, 50] > norm = colors.BoundaryNorm(ticks, colourmap.N) > im = m.imshow(data, colourmap, norm=norm, interpolation='nearest') > pos = ax.get_position() > l, b, w, h = pos.bounds > cax = plt.axes([l+w+0.045, b, 0.05, h]) > cbar = mpl.colorbar.ColorbarBase(cax, cmap=colourmap, norm=norm, > ticks=ticks) > plt.show() > > Many thanks, > > Martin > -- View this message in context: http://old.nabble.com/Exclude-colour-from-a-colourbar-tp29699746p29702394.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users