31
$\begingroup$

I have figures containing several arcs showing the extend of angular measures, and would like to indicate the directions in which angles are measured with arrowheads. How do I add an arrowhead at the "ends" of these arcs? (The "arrowheads" panel in the drawing tools palette is, worryingly, disabled.)

For example, I have something like this to start with:

enter image description here


Show[
 Graphics[{Red, Circle[{0, 0}, 1, {0 Degree, 90 Degree}]}],
 Graphics[{Blue, Circle[{0, 0}, 1.25, {0 Degree, 270 Degree}]}],
 Graphics[{Green, Circle[{0, 0}, 1.5, {0 Degree, 180 Degree}]}]]
$\endgroup$
  • 1
    $\begingroup$ Does this help: mathematica.stackexchange.com/questions/11545/… $\endgroup$ – s0rce Oct 23 '12 at 22:31
  • 1
    $\begingroup$ All I can come up with is something like Graphics[Arrow[ BezierCurve[{Sin[#], Cos[#]} & /@ Range[0, Pi, .01]]]]. That can't be the right approach, can it? $\endgroup$ – orome Oct 23 '12 at 22:47
  • 3
    $\begingroup$ Since Arrow[] can take BSplineCurve[] arguments, you can use the functions in this question to get circular arcs with arrow heads. Witness for instance Arrow[BSplineCurve[{{1, 0}, {1, Sqrt[3]}, {-1/2, Sqrt[3]/2}}, SplineDegree -> 2, SplineKnots -> {0, 0, 0, 1, 1, 1}, SplineWeights -> {1, 1/2, 1}]] // Graphics $\endgroup$ – J. M. is away Oct 23 '12 at 23:40
  • 2
    $\begingroup$ Possible duplicate: stackoverflow.com/questions/5705243/… $\endgroup$ – DavidC Oct 24 '12 at 4:29
27
$\begingroup$
 Show[ParametricPlot[#[[1]]*{Cos[θ], Sin[θ]}, {θ, #[[2]], #[[3]]},
    Axes -> False, PlotStyle -> #[[4]]] /.
  Line[x_] :> Sequence[Arrowheads[{-0.05, 0.05}], Arrow[x]] & /@ 
   {{1, 0 Degree, 90 Degree, Red}, {1.25, 0 Degree, 270 Degree, Blue},
    {1.5, 0 Degree, 180 Degree, Green}},
 PlotRange -> All]

enter image description here

Update: A function using a single ParametricPlot with multiple circles with arrows:

 ClearAll[arcsWArrows];
 arcsWArrows[args1 : {{_, {_, _}} ..}, dir_List: {Directive[GrayLevel[.3], 
 Arrowheads[{{-0.05, 0}, {0.05, 1}}]]}] :=
   ParametricPlot[ Evaluate[#[[1]]*{ Cos[Rescale[u, {0, 2 Pi}, Abs@#[[2]]]], 
     Sin[Rescale[u, {0, 2 Pi}, Abs@#[[2]]]]} & /@ args1],
    {u, 0, 2 Pi}, PlotStyle -> dir, Axes -> False,
     PlotRangePadding -> .2, ImageSize -> 200] /. 
  Line[x_, ___] :> Arrow[x]

Usage:

rdsAndAngls = {{1, {0, π/2}}, {1.25, {0, π}}, {1.5, {0, (3 π)/2}}, {2, {π/4, (4 π)/2}}};
directives = {Directive[Red, Thick,  Arrowheads[{{-0.05, 0}, {0.05, 1}}]],
    Directive[Blue, Dashed, Arrowheads[{{-0.05, 0}, {0.05, 1}}]],
    Directive[Green, Arrowheads[{{-0.05, 0}, {0.05, 1}}]],
    Directive[Orange, Thickness[.02],  Arrowheads[{{-0.07, 0}, {0.07, 1}}]]};

Row[{arcsWArrows[rdsAndAngls], 
       arcsWArrows[rdsAndAngls, {directives[[1]]}],
       arcsWArrows[rdsAndAngls, directives], 
       arcsWArrows[rdsAndAngls, directives[[-1 ;; 2 ;; -1]]]}]

enter image description here

$\endgroup$
  • $\begingroup$ Would you please add some explanations on what the part ` Line[x_] :> Sequence[Arrowheads[{-0.05, 0.05}], Arrow[x]]` is doing. :) $\endgroup$ – H. R. May 20 '17 at 20:13
8
$\begingroup$

You can approximate a Circle with a Line or Arrow, if reasonable resolution is given:

Circle[o_, r_, {a_, b_}] -> Arrow@Table[{Cos[k], Sin[k]}*r + o, {k, a, b, (b-a)/res}]

where res gives the resolution of the line. The replacement can be done at the first call of Graphics on the arguments or even after, on the InputForm version of the resulting figure.

To see it in action:

Manipulate[
 pts = N@Table[{Cos[k], Sin[k]}*r + o, {k, α Degree, β Degree, (β Degree - α Degree)/d}];
 Show[
  Graphics[{Lighter@Pink, AbsoluteThickness@10, Circle[o, r, {α Degree, β Degree}]}],
  Graphics[{Arrow[pts, 0]}],
  PlotRange -> {{-1.3, 1.3}, {-1.3, 1.3}}, AspectRatio -> 1, 
  Axes -> True, ImageSize -> 250
 ],
 {{d, 20, "res."}, 1, 100, Appearance -> "Labeled"},
 {{α, 0, "α"}, 0, 360, Appearance -> "Labeled"},
 {{β, 250, "β"}, 0, 360, Appearance -> "Labeled"},
 {{r, 1, "r"}, 0.01, 2, Appearance -> "Labeled"},
 {{o, {0, 0}, "origo"}, {-1, -1}, {1, 1}},
 ControlPlacement -> Left
]

Mathematica graphics

$\endgroup$
  • $\begingroup$ (+1) for nice explanations! :) $\endgroup$ – H. R. May 20 '17 at 20:11
6
$\begingroup$

Perhaps somebody finds this useful

Graphics[{Arrowheads[{-0.05, 0.05}],GraphicsComplex[Table[{Re[Exp[I*g]],Im[Exp[I*g]]},
{g,Subdivide[Pi/4,2/3 Pi, 100]}], Arrow[Range[101]]]},
PlotRange -> {{-1, 1}, {-1, 1}}, Axes -> True]

enter image description here

$\endgroup$
  • 2
    $\begingroup$ I should be able to just say Arrow[Circle[{0,0},1,{0,Pi/4}]], but Wolfram's never been one to do things the right way. $\endgroup$ – Travis Bemrose Dec 11 '17 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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