I stumbled upon some odd behaviour in Plot that does not really make sense to me. I stumbled on it with a more complicated scenario, but a distilled demo is below.
If I make some data
data = {Sin[x], Sin[2 x], Sin[3 x]};
Then plot it using this code, the lines have different colours
Plot[data, {x, 0, 2 Pi}]
If I plot the same lines using Part as in this code, the lines are all the same colour
Plot[data[[All]], {x, 0, 2 Pi}]
If I use Part but prior to create a new variable
data2 = data[[All]]
Then plot
Plot[data2, {x, 0, 2 Pi}]
The lines regain their different colours.
Obviously Mathemtica is treating the second example as different somehow. But to me, this seems rather unintuitive. Is there a reason for this behaviour and is it intended? If intended, why is it there / what is it useful for?
HoldAllattribute ofPlot. Look at what happens when you evaluatePlot[data[[All]] // Evaluate, {x, 0, 2 Pi}]. (See this as well.) – J. M.'s missing motivation May 26 '22 at 12:50With[{list = Table[x^n,{n,1,10}]},Plot[list,{x,0,1}]– Craig Carter May 26 '22 at 15:40