使用颜色图散点以增加索引

Scatter points with colormap for increasing indices

如何根据索引为散点着色?例如,我希望具有较小索引的点具有 Blues 颜色图的较浅颜色,而具有较大索引的点具有较深的颜色。

from numpy.random import randn
import matplotlib.pyplot as plt


points = randn(20, 2)
plt.scatter(*points.T)

看看这个

x = range(20)
plt.scatter(x, x, c=x, cmap=plt.get_cmap('Blues'))

看来您可以将索引传递给 c 参数