# Vary the color of a 2D scatter plot [duplicate]

This is what I want.

I want to change the colors as I progress through a list. I have always felt that Mathematica's ListPlot needed this feature. It is possible that a feature like this has been added in version 10.1, but prior to that, the best I know of is to use Graphics directly, which isn't nearly as hard as it sounds:

points = Table[{x^4, Sin[x^4]}, {x, 0, (2*Pi)^(1/4), 0.01}];
colors = Map[Hue[2/3*(#[]/(2*Pi))] &, points]; This is pretty close; if you want to make it look more like the ListPlot, you'll want to add axes and maybe change the aspect ratio:

Graphics[
AspectRatio -> 1/GoldenRatio,
Axes -> True] • Does using ColorFunction with ListPlot, allow you to apply a custom list of colors to the plot points? Last I remember looking into it, you would have to look them up in a table or something to figure out how to match the colors to the points. – nben May 9 '15 at 0:50
• The question isn't very specific, but the example plot clearly doesn't vary with x or y in a trivial way, which is all the docs seem to imply that you can do with ColorFunction. – nben May 9 '15 at 1:03

For illustrative purposes:

f[t_] := {Sqrt Cos[t], Sqrt Cos[t] Sin[t]}/(1 + Sin[t]^2)
r = Range[0, 2 Pi, 0.05];
cf = ColorData["Rainbow"][1 - #/(2 Pi)] &;
lp = ListPlot[{f@#} & /@ r, PlotStyle -> (cf /@ r),
AspectRatio -> Automatic, ImageSize -> 400];
g = Graphics[{cf@#, PointSize[0.01], Point[f@#]} & /@ r,
ImageSize -> 400];
pp = ParametricPlot[f[t], {t, 0, 2 Pi},
ColorFunction -> (cf[2 Pi #3] &), PlotStyle -> Thickness[0.01],
ImageSize -> 400];
Grid[Transpose[{{"ListPlot", "Graphics", "ParametricPlot"}, {lp, g,
pp}}]] 