Message Boards Message Boards

0
|
3229 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How alternate colors in dashed arrows?

How might I alternate two colors, say Red and Blue, for the dashes on a pair of oppositely pointing arrows, such as in the following, so that the gaps between the blue dashes are filled with red dashes and vice versa?

Note that, for reasons beyond the scope of this question, I do not want to use a single arrow having two arrowheads, that is, I do not want to use something like Arrowheads[{-0.03,0.03}]that puts arrowheads on both ends of a single arrow.

enter image description here

(Cross-posted from https://mathematica.stackexchange.com/q/264101/148)

POSTED BY: Murray Eisenberg
5 Replies

Thanks to all who replied. The method I'll use is to draw the first arrow solid and then overlay that with the second arrow dashed. This has the desired effect of alternating colors.

POSTED BY: Murray Eisenberg

Or maybe this is a bit better

p1 = {.5, 2};
p2 = {3.7, 4.5};
g1[t_] := p1 (1 - t) + p2 t
pl1 = Graphics[{Red, Arrow[{g1[.1], p1}], Blue, Arrow[{g1[.9], p2}]}];
pl2 = Graphics[{Thick, Red, 
    Table[Line[{g1[2 j/10], g1[(2 j + 1)/10]}], {j, 0, 4}], Blue, 
    Table[Line[{g1[(2 j + 1)/10], g1[(2 j + 2)/10]}], {j, 0, 4}]}];
Show[pl1, pl2]
POSTED BY: Hans Dolhaine

What about this? Not ideal, but a 1st approach

p1 = {.5, 2};
p2 = {3.7, 4.5};
g1[t_] := p1 (1 - t) + p2 t
pl1 = Graphics[{Red, Arrow[{g1[.1], p1}], Blue, Arrow[{g1[.9], p2}]}];
line1 = Graphics[{Red, Dashing[.1], Line[{g1[.1], g1[.9]}]}];
line2 = Graphics[{Blue, Dashing[.05], Line[{g1[.1], g1[.9]}]}];
Show[pl1, line1, line2]
POSTED BY: Hans Dolhaine

No, unfortunately, such bowed arrows would not be appropriate. The reason is that the arrows are meant to help visualize a function of the disk to itself (and the inverse of that function), that operates linearly on radii of the disk. Bowed arrows are therefore misleading.

POSTED BY: Murray Eisenberg

Hello Murray,

I guess Dashing[] is well dicussed on SE. Here is just another idea: If the basic problem is to distinguish two arrows which are aligned and only differ in direction, would something like this work for you?

arrw[{p1_, p2_}] := Module[{d, p11, s, p3},
  d = p2 - p1;
  p11 = p1 + .06 d;
  s = Normalize@Reverse[d] {1, -1};
  p3 = Mean[{p1, p2}] + .03 s Norm[d];
  Arrow@BezierCurve[{p11, p3, p2}]
  ]

{p1, p2} = {{1, 2}, {3, 5}};
Graphics[{Arrowheads[.1], Red, arrw[{p1, p2}], Blue, arrw[{p2, p1}]}]

enter image description here

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract