I am using Mathematica 8. In Mathematica, there is a default PlotStyle
coloring in Plot
and ListPlot
. For example, suppose I have a series of nine functions stored in the list functions
. Mathematica styles the different curves in a cyclic way (I think that the default is cycles of "blue", purple, dark yellow, green), as in this example:
functions = Table[a*Cos[x], {a, 0.2, 1, 0.1}]
Plot[functions, {x, 0, 2 Pi}]
{0.2 Cos[x], 0.3 Cos[x], 0.4 Cos[x], 0.5 Cos[x], 0.6 Cos[x], 0.7 Cos[x], 0.8 Cos[x], 0.9 Cos[x], 1. Cos[x]}
This is nice, but now suppose that I want to color the multiple curves using some sort of gradient (perhaps one of the gradients in ColorData
). Is this possible in Plot
and ListPlot
?
I could do this somewhat manually. For example, if I wanted a blue gradient, I could write the following (although this choice of colors could somehow be improved):
Plot[functions, {x, 0, 2 Pi}, PlotStyle -> {
Lighter[Lighter[Lighter[Lighter[Blue]]]],
Lighter[Lighter[Lighter[Blue]]],
Lighter[Lighter[Blue]],
Lighter[Blue],
Blue,
Darker[Blue],
Darker[Darker[Blue]],
Darker[Darker[Darker[Blue]]],
Darker[Darker[Darker[Darker[Blue]]]]
}]
However, this becomes complicated if I have many curves or if I want to use a more complex gradient such as rainbow (e.g., ColorData["Rainbow"]
), temperature map (e.g., ColorData["TemperatureMap"]
), etc. Do you have any suggestions?
Plot[Evaluate@Table[Sin[x] + t, {t, 0, 1, .1}], {x, 0, Pi}, PlotStyle -> Table[Blend[{White, Blue, Black}, i], {i, 0, 1, .1}]]
Blend works also with palletes.Blend["Rainbow",x]
$\endgroup$Table[i/Length[functions], {i, 1, Length[functions]}]
, as halirutan does below. $\endgroup$