0

How do you color the scatter points based on their index? For instance, I would like points with smaller indices to have a lighter colour of the Blues colormap and the ones with larger indices to have a darker colour.

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


points = randn(20, 2)
plt.scatter(*points.T)
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Euler_Salter
  • 3,271
  • 8
  • 33
  • 74
  • 2
    Does this answer your question? [Scatter plot and Color mapping in Python](https://stackoverflow.com/questions/17682216/scatter-plot-and-color-mapping-in-python) – Jody Klymak Jan 11 '22 at 10:01

1 Answers1

1

Look at this one

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

It seems you can just pass the indices to c argument

bottledmind
  • 603
  • 3
  • 10