Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Imagine I have some data in a list I'd like to plot using ListPlot in Mathematica 9, for example:

ListPlot[Table[{i, Cos[i]}, {i, 1, 10^3}]]

How can I specify that the data points should be colored according to a linearly scaling interval from one RGB value to another (e.g. Red --> Blue, Green --> Red, etc.) depending on the point's index in the array? Can we do something similar using ListPointPlot3D?

ListPointPlot3D[Table[{i, Cos[i], Sin[i]}, {i, 1, 10^3}]] 
share|improve this question
    
Have you looked at ColorFunction‌​? – Ali Jun 28 '13 at 5:45
    
@Ali Yes, but I couldn't see how to make it work with the index of the datapoints instead of their values? – FlavorOfLife Jun 28 '13 at 6:22
    
How is this: ListPointPlot3D[Table[{i, Cos[i], Sin[i]}, {i, 1, 10^3}], ColorFunction -> Function[{x, y, z}, Hue[x]]] – Ali Jun 28 '13 at 6:27
    
ColorFunctionScaling -> False will pass the unscaled x coordinate of the point to the colour function (I think). – cormullion Jun 28 '13 at 7:19
up vote 3 down vote accepted

One possibility:

ListLinePlot[Table[{i, Cos[i]}, {i, 1, 10^3}], 
    ColorFunction -> Function[{x, y}, ColorData["NeonColors"][x]]]

enter image description here

You might want to choose a less garish color set.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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