I am afraid I'm having an xy-problem, so I will try to start by describing my context.
I have a function that depends on two variables, one of which I call a parameter. I want to make a plot of the function for multiple values of the parameter, in order to visualize the smooth dependence on the parameter. To emphasize the smoothness, I also want the plots to gradually change color, say from Red to Blue.
My (example) code is below:
f[x_, m_] = PDF[ NormalDistribution[ m, 1 ], x ];
blendLst[ cc_, lst_] := Blend[ cc , #] & /@ Subdivide[ 0, 1, Length@lst - 1]
ms = Range[ 0, 10]/2;
Plot[ Evaluate[Table[ f[x, m], { m , ms}]], { x , - 4, 9}, PlotStyle -> blendLst[ {Red, Blue}, ms] ]
In this code, I have to make the function that blends the colors aware of the number of curves to be plotted. In this example, this is sort of automatic, but I can imagine a situation in which the Table
is evaluated separately. Then I'd have to plug the number manually. This goes against the rule to not repeat yourself and hence is error-prone.
Is there a way to define the color-blending function in a way that it'd require only the colors as arguments, but would somehow learn the total number of required colors from the context? So my desired function betterBlend
would work somewhat like
Plot[ listOfFunctions, { x , - 4, 9}, PlotStyle -> betterBlend[ {Red, Blue}] ]