0
$\begingroup$

I am using this code

h := Cos[3 x] + ((2 + x Cot[2 x] - x Cos[y] Csc[2 x]) Sin[3 x])/x;
g := Cos[3 x] + ((1 + 2 x Cot[2 x] - x Cos[y] Csc[x] Sec[x]) Sin[ 3 x])/(2 x);
F := -((3 Sin[3 x])/(2 x)) -  Sqrt[-1 + (Cos[ 3 x] + ((2 + x Cot[2 x] - x Cos[y] Csc[2 x]) Sin[3 x])/x)^2];
W := -((3 Sin[3 x])/(2 x)) +  Sqrt[-1 + (Cos[ 3 x] + ((2 + x Cot[2 x] - x Cos[y] Csc[2 x]) Sin[3 x])/x)^2];
pl := Plot[2, {x, 0, 5}, PlotRange -> {0, 2.5},  AxesLabel -> {"x", " "}];

 With[{rat =  F /. {{f_ :> f}, {r : Sqrt[_] :> -r}} // Apply@Times // Expand // 
    Simplify, F = F, g = g,  rat2 = W /. {{s_ :> s}, {q : Sqrt[_] :> -q}} // Apply@Times //  Expand // Simplify, W = W},

Manipulate[ 
Show[

pl, 

Normal@Plot[   1   , {x, 0, 5}, PlotRange -> {0, 2.5}, PlotPoints -> 200, PerformanceGoal -> "Speed", 
MeshFunctions -> {Function @@ {x, rat}}, 
MeshStyle -> Directive[PointSize[Large], Red], Mesh -> {{0}}, 
PlotLegends -> "\[FilledSmallCircle]  RedPoint"] /. 
Point[p_] :> Point[p /. {x_Real, z_Real} :> {x, 1.5}] // 
DeleteCases[#, Point[{x0_, _}] /;  Abs[F /. x -> x0] > 0.1 || Abs[g^2 - 1 /. x -> x0] < 0.01 , Infinity] &,

Normal@Plot[   1    , {x, 0, 5}, PlotRange -> {0, 2.5}, PlotPoints -> 200, PerformanceGoal -> "Speed", 
MeshFunctions -> {Function @@ {x, rat2}}, 
MeshStyle -> Directive[PointSize[Large], Blue], Mesh -> {{0}}, 
PlotLegends -> "\[FilledSmallCircle]  BluePoint"] /. Point[p_] :> Point[p /. {x_Real, z_Real} :> {x, 1.5}] // 
DeleteCases[#,  Point[{x0_, _}] /;  Abs[W /. x -> x0] > 0.1 || Abs[g^2 - 1 /. x -> x0] < 0.01 , 
 Infinity] &]
  
, {y, -4, 0}  ]]  

and I get

enter image description here

Question. How can I change those black points in legends from black to red and blue (as shown in the picture)?

$\endgroup$

1 Answer 1

3
$\begingroup$

Replace

PlotLegends -> "\[FilledSmallCircle]  RedPoint"

by

PlotLegends -> PointLegend[{Red}, {"RedPoint"}]

and similarly for the blue point.

$\endgroup$
2
  • $\begingroup$ Thanks. I have another related question: if I use some special characters as the legend, say *, +, ..., then, is it possible to have them in color form? $\endgroup$
    – math2021
    Jan 27, 2022 at 20:45
  • 2
    $\begingroup$ Try Style["+", Red]. $\endgroup$ Jan 27, 2022 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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