Index: /trunk/Ohana/src/opihi/cmd.astro/cplot.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/cplot.c	(revision 14065)
+++ /trunk/Ohana/src/opihi/cmd.astro/cplot.c	(revision 14066)
@@ -3,6 +3,6 @@
 int cplot (int argc, char **argv) {
   
-  int i, kapa, Npts, status;
-  float *x, *y, *r, *d, Rmin, Rmax;
+  int i, kapa, Npts, status, leftside;
+  float *x, *y, *r, *d, Rmin, Rmax, Rmid;
   Vector Xvec, Yvec, *xvec, *yvec;
   Graphdata graphmode;
@@ -17,4 +17,5 @@
   Rmin = graphmode.coords.crval1 - 182.0;
   Rmax = graphmode.coords.crval1 + 182.0;
+  Rmid = 0.5*(Rmin + Rmax);
 
   /* find vectors */
@@ -42,5 +43,14 @@
     while (*r < Rmin) *r += 360.0;
     while (*r > Rmax) *r -= 360.0;
+
+    // for pair-by-pair connections, check on second point if we straddle the back midline
+    if ((graphmode.ptype == 100) && (i % 2)) {
+      leftside = (r[-1] < Rmid); // if first of the pair is left, second must be as well
+      if ( leftside && (r[0] > Rmid + 90)) { r[0] -= 360.0; }
+      if (!leftside && (r[0] < Rmid - 90)) { r[0] += 360.0; }
+    }
     status = fRD_to_XY (x, y, *r, *d, &graphmode.coords);
+
+    // if we fail on one of the points, drop the corresponding pair
     if (!status) {
       if (graphmode.ptype == 100) {
