5

I try to draw a diagram with XY-pic. The following code already works pretty good, but I have a problem with the "go-around arc".

XY-pic diagram

\documentclass{article}
\usepackage[all]{xy}

\begin{document}

\[
\xymatrix@C=5mm@R=10mm{
    &&&&&&&&&&&& \\
    {\bullet}\ar[ru]^A\ar[rr] && {\bullet}\ar[r]\ar[ru]^B & {\bullet}\ar[r] & {\bullet}\ar[rrr]\ar[ru]^D &&& {\bullet}\ar[r] & {\bullet}\ar[rrr]\ar[ru]^F &&& {\bullet}\ar[r] & {\bullet}\ar`^u[u]`/20pt[ul]`[ullllllllllll]`l[llllllllllll][llllllllllll] \\ %\ar`^l[llllllllllll]`_dr[llllllllllll][llllllllllll] \\
    && \ar[ru]_C &&&& \ar[ru]_E &&&& \ar[ru]_G & \ar[ru]_H &
}
\]

\end{document}

I want to achieve the following two things:

  1. The bending on the right side should be a half-circle.
  2. The bending on the left side should be equal to the right side.

I tried for hours and couldn't get this to work. What is wrong?

3
  • +1 for heroic use of xypic - surely this would be easier to draw in TikZ or Metapost or PStricks?
    – Thruston
    Mar 9, 2016 at 18:29
  • Out of interest, what does the (corrected) diagram mean?
    – Thruston
    Mar 12, 2016 at 23:18
  • @Thruston It's the departures (A,B,D,F) and arrivals (C,E,G,H) at a certain airport over time. Mar 13, 2016 at 15:47

2 Answers 2

3

After an hour of careful study of The XY Guide I have a solution for you. I'll do my best to explain it below.

First here is the output enter image description here

And here is the LaTeX source:

\documentclass[border=5mm]{standalone}
\usepackage[pdf, matrix, arrow, curve]{xy}
\begin{document}
\begin{xymatrix}@C5mm@R10mm{
        &&&&&&&&&&&&
        \\
        &
        \bullet  \ar[rr]   \ar[ru]^{A} &&
        \bullet  \ar[r]    \ar[ru]^{B} &
        \bullet  \ar[r]    &
        \bullet  \ar[rrr]  \ar[ru]^{D} &&&
        \bullet  \ar[r]    &
        \bullet  \ar[r]    \ar[ru]^{F} &
        \bullet  \ar[r]    &
        \bullet  \ar@{->} `r/5mm[u]
                          `[u]
                          `[lllllllllll]
                          `[l]
                           [llllllllll]
\\
 &&&\ar[ru]_C
&&&&\ar[ru]_E
  &&\ar[ru]_G
   &\ar[ru]_H
\\} 
\end{xymatrix}
\end{document}

Notes

  • This is more or less as you had it apart from the loop back arrow.

  • My arrow has four curved segments.

    • The first one `r/5mm[u], says "add a curve starting to the right with radius 5mm, ending in the direction of the node that is up from the start point".

    • The second one `[u] says "add a curve with the same radius starting from where we are and ending in the direction of the node that is up from the original start point"

    • The third one `[lllllllllll] says "add a long straight segment ending in a quarter curve that points at the node that is lots of places left of the original start point (which is still node H)

    • The fourth one `[l] says "add a quarter curve from where we have got to ending up point in the direction of the node that is one place to the left of where we started". Extra ells here would make no difference.

  • Finally you have to give a target for the end of the arrow, so I've added [llllllllll] to point at the node that is 10 places to the left of H (ie A). Note that there's no back tick on this last one.

  • If you want more rounded curves you should reduce the row height rather than increase the radius. If you experiment you will see that the arrow position gets messed up as you increase the radius more that half the row height.

0
4

Here's a luamplib version (LuaLatex + Metapost) while you are waiting for xypic debugging assistance...

enter image description here

With comments in-line:

\documentclass[border=5mm]{standalone}
\usepackage{fontspec}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);

u := 10mm;  % unit scale

z.A = origin;  % points for each bullet
z.B = (2u,0);
z.C = (3u,0);
z.D = (4u,0);
z.E = (7u,0);
z.F = (8u,0);
z.G = (10u,0);
z.H = (11u,0);

% define two handy arrow paths, 
path arrow_away, arrow_into; 
arrow_away = origin -- right scaled 2u rotated 57;
arrow_into = arrow_away shifted - point 1 of arrow_away;

% make the arrow heads narrower
ahangle := 30;

% draw dots and away arrows
forsuffixes $=A,B,D,F:
   drawdot z$ withpen pencircle scaled 3;
   drawarrow subpath (0.1, 0.9) of arrow_away shifted z$;
   label.ulft("$" & str $ & "$", point 0.5 of arrow_away shifted z$);
endfor

% draw dots and into arrows
forsuffixes $=C,E,G,H:
   drawdot z$ withpen pencircle scaled 3;
   drawarrow subpath (0.1, 0.9) of arrow_into shifted z$;
   label.lrt("$" & str $ & "$", point 0.5 of arrow_into shifted z$);
endfor

% macro to save typing
vardef connect(expr a, b) =
  drawarrow a--b cutbefore fullcircle scaled 0.4u shifted a
                 cutafter  fullcircle scaled 0.4u shifted b;
enddef;
connect(z.A,z.B);
connect(z.B,z.C);
connect(z.C,z.D);
connect(z.D,z.E);
connect(z.E,z.F);
connect(z.F,z.G);
connect(z.G,z.H);

% do the loop connection separately
drawarrow z.H { right } .. { left } 
          point 1 of arrow_away shifted z.H shifted 5 right  
          --
          point 1 of arrow_away shifted z.A shifted 5 left  
          { left } .. { right } z.A
          cutbefore fullcircle scaled 0.4u shifted z.H
          cutafter  fullcircle scaled 0.4u shifted z.A;

endfig;
\end{mplibcode}
\end{document}

If you prefer a less slanted style of curve you could replace the go-around arrow with this:

drawarrow halfcircle rotated -90 shifted 1/2 up scaled 1.7u shifted z.H --
          halfcircle rotated +90 shifted 1/2 up scaled 1.7u shifted z.A
          cutbefore fullcircle scaled 0.4u shifted z.H
          cutafter  fullcircle scaled 0.4u shifted z.A;

to get: enter image description here

2
  • Thank you very much. I think once I have time, I will look into LuaLaTeX and - as I understand it, this would help here as well - Tikz. But it's a little late to do that for my thesis. ;-) I'll wait with accepting your answer if somebody comes along with some xypic help. Mar 10, 2016 at 9:37
  • Sure TikZ is the popular alternative - I have tried on several occasions to get my head around the xypic syntax - I think the guys that designed it were brought up on APL.
    – Thruston
    Mar 10, 2016 at 15:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .