This question already has an answer here:

I'm working with a ListPlot of several points.

I'd like to plot the points with a gradient of colors (for example, from blue to red) following their position in the x-axes.

For example:

x = {0,1,2,3,4,5,6,7,8,9,10};
y = {1,3,5,3,1,4,7,10,5,0,1};
data = Transpose@{x, y};
myplot = ListPlot[data]

That plots appears as:

enter image description here

I'd like to have a continuous change of the markers' colors, from blue tonalities in the left (near to x = 0) to red tonalities in the right (near x = 10).

What command should I use inside the ListPlot?

Thank you very much for your time!


marked as duplicate by MarcoB, Jason B. plotting Jun 27 '18 at 16:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


For ListPlot, one easy way to go is to wrap the data points in Style:

        Style[#, Blend[{Blue, Red}, #[[1]] / 10.]]&,

enter image description here


Not the answer you're looking for? Browse other questions tagged or ask your own question.