Jérôme Belleman
Home  •  Tools  •  Posts  •  Talks  •  Travels  •  Graphics  •  About Me

Drawing a Biologist's Looping Arrow with TikZ

11 Nov 2009

These arrows label something on a diagram and they make a loop to avoid being mistaken for e.g. a vector. TikZ offers the coil decoration which is used here.

1 Using the Coil Decoration

Using the coil decoration can be somewhat tricky. This recipe illustrates how to use it to draw a biologist's arrow:

  1. You'll need to \usetikzlibrary{decorations.pathmorphing} first.
  2. A bare-bones coil could be made with something like:

    \draw[->,decorate,decoration={coil}] (0,0) -- (45:2);
    This would yield a picture similar to this one:
    blah
  3. For the time being, we have a zigzagging path: that's because we look at the coil from its side; in order to see a loop, you need to shift your point of view left or right with the aspect parameter (which defaults to 0.5):
    blah
    Note that the more you shift, the more the loop will look like perfect circles until, at some point, you look down the coil.
  4. Let's try to have a bigger loop: you can perform this by tuning the amplitude parameter, which is the radius of the coil (in points). The following is drawn with amplitude=10:
    blah
  5. The next problem we want to address is the little stretch at the end of the coil, right before the arrow which has the arrow point to a possibly irrelevant heading; we'd rather have the arrow be drawn somewhere in the loop. I haven't yet come across a better idea than actually reversing the path, i.e. drawing the path backwards and having the arrow point backwards. On top of that, you'll need to swap the aspect as well (aspect=-1.1), otherwise, you'll loop in the wrong direction; and that'll have you swap the amplitude as well, otherwise the arrow will sort of point inside the loop instead of outside:

    \draw[<-,decorate,decoration={coil,aspect=-1.1,
     amplitude=-10}] (0,0) ++(45:2) -- +(45:-2);
    blah
  6. Now, you'll need to have the path loop only once: this is done by setting the segment length parameter accordingly (in points). Here, I've set segment length=14, which is the shortest possible length such that there's only one loop (segment length=13 would have been short enough a segment to fit two loops on the 2 cm path we're dealing with):
    blah
    The problem here is that there's a straight stretch of line at the beginning (i.e. end, but you see what where I'm going) of the path: by setting segment length=23, you'll have the path draw a segment as long as possible such that such a segment can still fit in the 2 cm path we have; that way, you'll shorten the straight stretch a good deal, possibly even visually completely. On top of that, this operation will have the arrow lift its nose a little, which isn't a bad thing:
    blah
  7. Removing the straight stretch of line completely isn't always possible: the best way to do so is to clip the path.

2 References