No idea how to get my scatter plot to talk to my colorbar. I have taken endless approaches and consulted every forum all to no avail. I am either very close or nowhere near, surly this should only be a one or two liner?? Please help.

import matplotlib.colors as cols
import as cm
import matplotlib.pylab as plt


alph and delt are numpy arrays of x and y coordinates, while dmag is numpy array of floats in the interval approx. [-0.6,0.8]. The result of running this cose is a scatter plot of black points alongside a colour bar ranging from -0.6 to 0.8. I want the scattered points to be colored according to values in dmag in the range -0.2 to 0.2 and want the colorbar over the range -0.2 to 0.2. I want the range -0.2 to 0.2 to reflect the entire colormap.

Thanks jrf.

The following now works.'RdYBlu')
    sc=plt.scatter(alph,delt,edgecolors='none',s=5,c=m.to_rgba(dmag),cmap=cmap, norm=norm)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.