ListPlot color function depending on point stability

I have the following code that finds the critical points of the function enAll[v1,vTotal] and there is a plot of those points as shown below. However, I need each point on the plot to be colored according to the stability of the point. How can I make a color function such that for each v1, it checks the corresponding value of mat[v1,vTotal], and it chooses the color of the point depending on whether mat[v1,vTotal] is positive or negative?

p1[x_] := InterpolatingPolynomial[{{0, 0}, {1 + 0.1, 5, 0}, {2 + 0.1, 3, 0}, {6, 6}}, x];
p2[x_] := InterpolatingPolynomial[{{0, 0}, {1, 5, 0}, {2, 3, 0}, {6, 6}}, x];
en1[v_] := FullSimplify[Integrate[p1[x], {x, 0, v}]];
en2[v_] := FullSimplify[Integrate[p2[x], {x, 0, v}]];
enAll[v1_, vTotal_] := en1[v1] + en2[vTotal - v1]
vec[v1_, vTotal_] := FullSimplify[D[enAll[v1, vTotal], v1]];
mat[v1_, vTotal_] := FullSimplify[D[enAll[v1, vTotal], v1, v1]];

Graphics[Point[Table[spliceThread[{v1 /. NSolve[vec[v1, vTotal] == 0 && v1 > 0 && vTotal >= v1, v1,
Reals], vTotal - v1 /. NSolve[vec[v1, vTotal] == 0 && v1 > 0 && vTotal >= v1, v1, Reals]}],
{vTotal, 1, 6, 0.01}]]]


• You need to provide complete code that runs. That includes the definitions of all involved functions, like en1, en2, spliceThread. Jul 11, 2023 at 16:51
• I just edited it to include en1,en2, and spliceThread Jul 11, 2023 at 17:41

Perhaps something like

vc[vTotal_?NumericQ] := v1 /.
NSolve[vec[v1, vTotal] == 0 && v1 > 0 && vTotal >= v1, v1, Reals]

coords = Table[spliceThread[{vc[vt], vt - vc[vt]}],  {vt, 1, 6, 0.01}];

ht = Flatten@Table[mat[vc[vt], vt] /. vt -> vT, {vT, 1, 6, .01}];

vertexColors = If[# >= 0, Red, Blue] & /@ ht;

Graphics[
GraphicsComplex[coords,
Point[Range @ Length @ coords, VertexColors -> Automatic],
VertexColors -> vertexColors]]


Also

ListPlot[List /@ coords,
PlotStyle -> vertexColors, AspectRatio -> 1, Axes -> False]


• That's exactly what I'm looking for. Thank you! Jul 11, 2023 at 17:44
• @juv95, you are most welcome.
– kglr
Jul 11, 2023 at 17:46