matplotlib colorbar para dispersão

Estou trabalhando com dados que possuem os dados com três parâmetros de plotagem: x, y, c. Como você cria um valor de cor personalizado para um gráfico de dispersão?

Extending thisexempl Estou tentando fazer:

import matplotlib
import matplotlib.pyplot as plt
cm = matplotlib.cm.get_cmap('RdYlBu')
colors=[cm(1.*i/20) for i in range(20)]
xy = range(20)
plt.subplot(111)
colorlist=[colors[x/2] for x in xy] #actually some other non-linear relationship
plt.scatter(xy, xy, c=colorlist, s=35, vmin=0, vmax=20)
plt.colorbar()
plt.show()

mas o resultado éTypeError: You must first set_array for mappable

questionAnswers(2)

yourAnswerToTheQuestion