3
$\begingroup$

I need a plot with arrows going to the left on some curves and to the right on others. I have not figured out how to do this within a single Plot command. When I make two plots and try to overlay them with Show, the arrows all point the same direction. Minimum Working Example:

P1 = Plot[{
  yh /. {a -> 4, b -> 1},
  yn /. {a -> 2, b -> .002, n -> 3.5}
  }, {x, -10, 10},
 Frame -> True, PlotRange -> {{-10, 10}, {-10, 10}},
 BaseStyle -> Arrowheads[Table[.03, {5}]],
 PlotStyle -> {Black}] /. Line -> Arrow
P2 = Plot[{
  -yh /. {a -> 4, b -> 1},
  -yn /. {a -> 2, b -> .002, n -> 3.5}
  }, {x, -10, 10},
 Frame -> True, PlotRange -> {{-10, 10}, {-10, 10}},
 BaseStyle -> Arrowheads[Table[-.03, {5}]],
 PlotStyle -> {Black}] /. Line -> Arrow
 Show[P1, P2]

Notice that the arrows in P2 (which are correct) and in the output of Show do not point the same direction.

$\endgroup$
  • $\begingroup$ You need to post the code for yh and yn. $\endgroup$ – kglr May 8 '17 at 1:26
2
$\begingroup$
yh = b x^(2 ) + a ; yn = b (a x)^(3) + n; (* replace these with your yh and yn *)
ah1 = Arrowheads[Table[.03, {5}]];
ah2 = Arrowheads[Table[-.03, {5}]]; 

Use a single Plot with PlotStyle specifying the Arrowheads for each curve:

Plot[{yh /. {a -> 4, b -> 1}, yn /. {a -> 2, b -> .002, n -> 3.5}, 
     -yh /. {a -> 4, b -> 1}, -yn /. {a -> 2, b -> .002, n -> 3.5}}, 
    {x, -10, 10}, 
    Frame -> True, PlotRange -> {{-10, 10}, {-10, 10}}, 
    PlotLegends -> {"yh /.{a -> 4,b ->1}",  "yn /.{a->2,b->.002,n->3.5}", 
    "-yh /.{a->4,b->1}", "-yn /.{a->2,b->.002,n->3.5}"},
    PlotStyle -> {Directive[ah1, Red], Directive[ah1, Green], 
    Directive[ah2, Blue], Directive[ah2, Orange]}] /. Line -> Arrow

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thanks!! I have never looked deeply enough to figure out the use of Directive. The results of this will show up in the next edition of my textbook. $\endgroup$ – Paul Drake May 8 '17 at 1:53
  • $\begingroup$ @Paul, my pleasure. Welcome to mma.se. $\endgroup$ – kglr May 8 '17 at 2:01

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.