# Provide a list of colours for the points of ListPlot

I want to colour the points in a ListPlot with a list of colours, i.e. something like

data = Table[Cos[x]^2, {x, 0, 10, 0.1}];
colourData = Table[Cos[x]^2, {x, 0, 10, 0.1}];
colours = (ColorData["TemperatureMap"][#] &) /@ colourData;
ListPlot[data,Joined->True (* Something like PlotStyle -> colours*)]


And I want an output that looks like this • Your data can be generated as data = Cos[Range[0, 10, 0.1]] – OkkesDulgerci Sep 19 at 14:58

Ok, I think I have something...

data = Table[Cos[x]^2, {x, 0, 10, 0.1}];
colourData = Table[Cos[x]^2, {x, 0, 10, 0.1}];
colours = (ColorData["TemperatureMap"][#] &) /@ colourData;
ListPlot[data, ColorFunction -> (Blend[colours, #] &), Joined -> True] This can be used when the data and colourData are different

data = Table[Cos[x], {x, 0, 10, 0.1}];
colourData = Table[Cos[x]^2, {x, 0, 10, 0.1}];
colours = (ColorData["TemperatureMap"][#] &) /@ colourData;
ListPlot[data, ColorFunction -> (Blend[colours, #] &), Joined -> True] This question is well covered in ListPlot's documentation on ColorFunction.

data = Table[Cos[x]^2, {x, 0, 10, 0.1}];
ListPlot[data, Joined -> True, ColorFunction -> "TemperatureMap"]


gets you • Thanks but this doesn't answer the question. This method only allows us to use the y values as data for the colour function. Not an arbitrary function, or an arbitrary list of colours. – Tom Sep 20 at 9:57