Adding arrows in a smooth curve?

How to put arrows in a closed curve?

You can add the arrows (or anything else) using the Epilog and Prolog options.

Sorry, I am new at using Mathematica. Could you give me more details, please?

I don’t understand where Arrow[] is to appear. Are the arrows to be on the two lines? Up or down? Or are the arrows to point to something?

The Arrows should show the orientation of the smooth closed curve and because I have to use Green Theorem, the orientation should be counterclockwise.

My old package CurvesGraphics6 was motivated precisely by this kind of problems. You can download it from https://www.dimi.uniud.it/gorni/Mma

Amelia,

I guess rather than ContourPlot you need/want ParametricPlot. If you want to do it in a clean way then you certainly should use Cianlucas package.

But just as a remark: In a “quick and dirty” way, the graphics can be tweaked simply like so:

pp = ParametricPlot[{{t^2, 8 t}/8, {2, -t}}, {t, -4, 4}, AxesLabel -> {x, y}, AxesOrigin -> {0, 0}, 
   PlotLegends -> {y^2 == 8 x, x == 2}, Axes -> True,  AxesStyle -> Black, Frame -> False, 
   PlotRange -> {{-1, 3}, Automatic}];
pp /. Line[pts__] :> {Arrowheads[{.1, #} & /@ Range[.1, 1, .1]], Arrow[pts]}

ADDENDUM: I missed that you want a counterclockwise version; here it is:

pp = ParametricPlot[{{t^2, -8 t}/8, {2, t}}, {t, -4, 4}, AxesLabel -> {x, y}, AxesOrigin -> {0, 0}, 
   PlotLegends -> {y^2 == 8 x, x == 2}, Axes -> True, AxesStyle -> Black, Frame -> False, 
   PlotRange -> {{-1, 3}, Automatic}];
pp /. Line[pts__] :> {Arrowheads[{.1, #} & /@ Range[.1, 1, .1]], Arrow[pts]}

Modifying the ContourPlot

It’s a two-step process: (1) Determine the orientations of the lines produced by ContourPlot. (2) Replace the lines by arrows with the corrected orientations.

Start with the contour plot:

cplot = ContourPlot[{y^2 == 8 x, x == 2}, {x, -5, 5}, {y, -5, 5}, 
   AxesLabel -> {x, y}, AxesOrigin -> {0, 0}, 
   PlotLegends -> "Expressions", Axes -> True, AxesStyle -> Black, 
   Frame -> False];

It’s probably unwise to predict (guess) how the lines will be oriented by ContourPlot. So first we replace the lines by arrows and see which point in the wrong direction:

orientation = {1, 1}; (* +1 = same, -1 = reverse *)
curvenumber = 0;
Normal@cplot /. Line[p_] :>
  {Arrowheads[orientation[[++curvenumber]] {0., 0.05, 0.05, 0.}], Arrow[p]}

The first (blue) path is oriented correctly; the second (gold) path needs to be reversed. We adjust orientation accordingly.

orientation = {1, -1}; (* +1 = same, -1 = reverse *)
curvenumber = 0;
Normal@cplot /. Line[p_] :>
  {Arrowheads[orientation[[++curvenumber]] {0., 0.05, 0.05, 0.}], Arrow[p]}

Because the OP mentioned Green’s Theorem

RegionBoundary will construct a correctly oriented boundary. DiscretizeRegion approximates the region boundary and sometimes struggles with corners. It this case, it does a good job.

reg = ImplicitRegion[y^2/8 <= x <= 2, {x, y}];

Show[
  HighlightMesh[
   DiscretizeRegion[RegionBoundary[reg]], {Style[0, None]}],
  AbsoluteOptions@cplot /. 
   fb_FormBox :> HoldForm @@ MakeExpression[fb, StandardForm]] /. 
 Line[p_] :> {Arrowheads[{0., 0.04, 0.04, 0.04, 0.04, 0.04, 0.04}], 
   Arrow[Append[#, First@#] &@
     RotateLeft[p[[All, 2]], 4]]} (* in effect rotates arrow heads *)

Thank you so much. Everything was really helpful.

Where I can learn to do those codes?

That’s a good question. I don’t have a good answer, but I’ll share what resources I know of and a little of my own experience. Wolfram has videos, classes, and the Tech. Conference. I’ve spent years on various WL/Mathematica sites. I’ve personally learned the most from the documentation and experimenting, but occasionally websites and Tech. Conferences show things that are not in the documentation. I’ve been using Mathematica since around 1990, so I’ve had some time to acquire knowledge about it. I’ve used it extensively in teaching, and solving problems to get a presentation to show exactly what I want has led me to try to understand precisely how things work. Nowadays with websites like this, I think the path to the right answer is easier: ask and probably someone has already figured out your problem. OTOH, one learns more by trying and failing. It’s a longer path to the right answer, but the unused things you learn often turn out to be useful later on. Solving my own problems has been a fairly successful method of learning for me in several areas, not just in WL/Mathematica. But do ask someone when you’re stuck. Formulating a question for someone else often reveals where misunderstanding or lack of knowledge lies. Sometimes I end up teaching myself something this way.

P.S.
Note that fb_FormBox :> HoldForm @@ MakeExpression[fb, StandardForm]] shouldn’t be necessary. It fixes what appears to be a bug in axes labels produced by AbsoluteOptions@cplot. I meant to mention that but forgot.