Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/cgrid.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 34490)
@@ -279,5 +279,5 @@
   graphmode.ptype = 100; /* connect a pair */
   graphmode.etype = 0;
-  PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
 
   free (Xvec.elements.Ptr);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/cplot.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/cplot.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/cplot.c	(revision 34490)
@@ -78,5 +78,5 @@
 
   graphmode.etype = 0;
-  PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   
   free (Xvec.elements.Ptr);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/czplot.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/czplot.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro/czplot.c	(revision 34490)
@@ -76,5 +76,5 @@
   graphmode.size = -1; /* point size determined by Zvec */
   graphmode.etype = 0;
-  PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, &graphmode);
+  PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, NULL, &graphmode);
 
   free (Xvec.elements.Flt);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/grid.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/grid.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/grid.c	(revision 34490)
@@ -178,5 +178,5 @@
   graphmode.ptype = 100; /* connect a pair */
   graphmode.etype = 0;
-  PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
 
   free (Xvec.elements.Flt);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/plot.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/plot.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/plot.c	(revision 34490)
@@ -3,5 +3,6 @@
 int plot (int argc, char **argv) {
   
-  int kapa, N, Npts;
+  char *out;
+  int kapa, N, Npts, valid, size, i;
   Graphdata graphmode;
   Vector *xvec, *yvec, *dxmvec, *dxpvec, *dymvec, *dypvec;
@@ -32,7 +33,27 @@
   }
 
-  if (argc != 3) {
+  valid  = (argc == 3);
+  valid |= (argc > 4) && !strcmp (argv[3], "where");
+  if (!valid) {
     gprint (GP_ERR, "USAGE: plot <x> <y> [style]\n");
+    gprint (GP_ERR, "   OR: plot <x> <y> [style] where (condition)\n");
     return (FALSE);
+  }
+
+  // tvec is used for logical test (truth vector)
+  Vector *tvec = NULL;
+  char *mask = NULL;
+  if (argc > 4) {
+    out = dvomath (argc - 4, &argv[4], &size, 1);
+    if (out == NULL) {
+      print_error ();
+      return FALSE;
+    }
+    if ((tvec = SelectVector (out, OLDVECTOR, TRUE)) == NULL) {
+      gprint (GP_ERR, " invalid logic result\n");
+      DeleteNamedVector (out);
+      free (out);
+      return (FALSE);
+    }
   }
 
@@ -53,4 +74,8 @@
     return (FALSE);
   }
+  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
+    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
+    return (FALSE);
+  }
   if (dypvec && (dypvec->Nelements != xvec->Nelements)) goto mismatch;
   if (dymvec && (dymvec->Nelements != xvec->Nelements)) goto mismatch;
@@ -59,17 +84,39 @@
 
   Npts = xvec[0].Nelements;
-  if (Npts == 0) return (TRUE);
+  if (Npts == 0) {
+    if (tvec) DeleteVector (tvec);
+    return (TRUE);
+  }
+
+  if (tvec) {
+    Npts = 0;
+    ALLOCATE (mask, char, tvec->Nelements);
+    for (i = 0; i < tvec->Nelements; i++) {
+      mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
+      if (!mask[i]) Npts ++;
+    }
+    if (Npts == 0) {
+      DeleteVector (tvec);
+      free (mask);
+      return TRUE;
+    }
+  }
 
   if (!KapaPrepPlot (kapa, Npts, &graphmode)) return (FALSE);
   
-  PlotVectorSingle (kapa, xvec, "x");
-  PlotVectorSingle (kapa, yvec, "y");
+  PlotVectorSingle (kapa, xvec, mask, "x");
+  PlotVectorSingle (kapa, yvec, mask, "y");
   if (graphmode.etype & 0x01) {
-    PlotVectorSingle (kapa, dymvec, "dym");
-    PlotVectorSingle (kapa, dypvec, "dyp");
+    PlotVectorSingle (kapa, dymvec, mask, "dym");
+    PlotVectorSingle (kapa, dypvec, mask, "dyp");
   }
   if (graphmode.etype & 0x02) {
-    PlotVectorSingle (kapa, dxmvec, "dxm");
-    PlotVectorSingle (kapa, dxpvec, "dxp");
+    PlotVectorSingle (kapa, dxmvec, mask, "dxm");
+    PlotVectorSingle (kapa, dxpvec, mask, "dxp");
+  }
+
+  if (tvec) {
+    free (mask);
+    DeleteVector (tvec);
   }
   return (TRUE);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/zplot.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/zplot.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/zplot.c	(revision 34490)
@@ -3,5 +3,6 @@
 int zplot (int argc, char **argv) {
   
-  int i, kapa;
+  char *outname;
+  int i, kapa, valid, size;
   opihi_flt *out;
   double min, range;
@@ -11,6 +12,9 @@
   if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
 
-  if (argc != 6) {
+  valid  = (argc == 6);
+  valid |= (argc > 7) && !strcmp (argv[6], "where");
+  if (!valid) {
     gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n");
+    gprint (GP_ERR, "   OR: zplot <x> <y> <z> min max where (condition)\n");
     return (FALSE);
   }
@@ -18,4 +22,21 @@
   min = atof(argv[4]);
   range = atof(argv[5]) - min;
+
+  // tvec is used for logical test (truth vector)
+  Vector *tvec = NULL;
+  char *mask = NULL;
+  if (argc > 7) {
+    outname = dvomath (argc - 7, &argv[7], &size, 1);
+    if (outname == NULL) {
+      print_error ();
+      return FALSE;
+    }
+    if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) {
+      gprint (GP_ERR, " invalid logic result\n");
+      DeleteNamedVector (outname);
+      free (outname);
+      return (FALSE);
+    }
+  }
 
   /* find vectors */
@@ -29,4 +50,8 @@
   if (xvec[0].Nelements != zvec[0].Nelements) {
     gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]);
+    return (FALSE);
+  }
+  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
+    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
     return (FALSE);
   }
@@ -46,11 +71,20 @@
   }
 
+  if (tvec) {
+    ALLOCATE (mask, char, tvec->Nelements);
+    for (i = 0; i < tvec->Nelements; i++) {
+      mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
+    }
+  }
+
   /* point size determined by Zvec */
   graphmode.style = 2; /* plot points */
   graphmode.size = -1; /* point size determined by Zvec */
   graphmode.etype = 0; /* no errorbars */
-  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);
+  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode);
 
   free (Zvec.elements.Ptr);
+  if (mask) free (mask);
+  DeleteNamedVector (outname);
 
   return (TRUE);
@@ -60,5 +94,6 @@
 int zcplot (int argc, char **argv) {
   
-  int i, kapa;
+  char *outname;
+  int i, kapa, valid, size;
   opihi_flt *out;
   double min, range;
@@ -68,6 +103,9 @@
   if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
 
-  if (argc != 6) {
-    gprint (GP_ERR, "USAGE: zplot <x> <y> <z> min max\n");
+  valid  = (argc == 6);
+  valid |= (argc > 7) && !strcmp (argv[6], "where");
+  if (!valid) {
+    gprint (GP_ERR, "USAGE: zcplot <x> <y> <z> min max\n");
+    gprint (GP_ERR, "   OR: zcplot <x> <y> <z> min max where (condition)\n");
     return (FALSE);
   }
@@ -75,4 +113,21 @@
   min = atof(argv[4]);
   range = atof(argv[5]) - min;
+
+  // tvec is used for logical test (truth vector)
+  Vector *tvec = NULL;
+  char *mask = NULL;
+  if (argc > 7) {
+    outname = dvomath (argc - 7, &argv[7], &size, 1);
+    if (outname == NULL) {
+      print_error ();
+      return FALSE;
+    }
+    if ((tvec = SelectVector (outname, OLDVECTOR, TRUE)) == NULL) {
+      gprint (GP_ERR, " invalid logic result\n");
+      DeleteNamedVector (outname);
+      free (outname);
+      return (FALSE);
+    }
+  }
 
   /* find vectors */
@@ -86,4 +141,8 @@
   if (xvec[0].Nelements != zvec[0].Nelements) {
     gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]);
+    return (FALSE);
+  }
+  if (tvec && tvec[0].Nelements != yvec[0].Nelements) {
+    gprint (GP_ERR, "logic test vector not the same length as data vectors\n");
     return (FALSE);
   }
@@ -103,11 +162,20 @@
   }
 
+  if (tvec) {
+    ALLOCATE (mask, char, tvec->Nelements);
+    for (i = 0; i < tvec->Nelements; i++) {
+      mask[i] = (tvec->type == OPIHI_FLT) ? (tvec->elements.Flt[i] == 0.0) : (tvec->elements.Int[i] == 0.0);
+    }
+  }
+
   /* point size determined by Zvec */
   graphmode.style = 2; /* plot points */
   graphmode.color = -1; /* point color determined by Zvec */
   graphmode.etype = 0; /* no errorbars */
-  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, &graphmode);
+  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode);
 
   free (Zvec.elements.Ptr);
+  if (mask) free (mask);
+  DeleteNamedVector (outname);
 
   return (TRUE);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/fitcolors.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/fitcolors.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/fitcolors.c	(revision 34490)
@@ -311,5 +311,5 @@
 	KapaBox (kapa, &graphdata);
 
-	PlotVectorPair (kapa, xvec, yvec, &graphdata);
+	PlotVectorPair (kapa, xvec, yvec, NULL, &graphdata);
 
 	for (i = 0; i < 11; i++) {
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/images.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/images.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/images.c	(revision 34490)
@@ -350,5 +350,5 @@
     graphmode.ptype = 100; /* connect pairs of points */
     graphmode.etype = 0;
-    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   }
 
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imbox.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imbox.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imbox.c	(revision 34490)
@@ -123,5 +123,5 @@
     graphmode.ptype = 100; /* connect pairs of points */
     graphmode.etype = 0;
-    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   }
 
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imdense.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imdense.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imdense.c	(revision 34490)
@@ -65,5 +65,5 @@
     graphmode.style = 2; /* points */
     graphmode.etype = 0;
-    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   }
 
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imstats.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imstats.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/imstats.c	(revision 34490)
@@ -54,5 +54,5 @@
   graphmode.style = 2;
   graphmode.etype = 0;
-  PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   
   free (Xvec.elements.Flt);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/lcurve.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/lcurve.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/lcurve.c	(revision 34490)
@@ -160,5 +160,5 @@
     PlotVectorPairErrors (kapa, &Xvec, &Yvec, &dYvec, &graphmode);
   } else {
-    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   }
 
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/procks.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/procks.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/procks.c	(revision 34490)
@@ -113,5 +113,5 @@
   graphmode.style = 2; /* set style to points */
   graphmode.etype = 0; /* no errorbars */
-  PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
 
   /* now plot vectors between two extrema */
@@ -146,5 +146,5 @@
   graphmode.etype = 0; /* no errorbars */
 
-  PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
 
   free (Xvec.elements.Flt);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/showtile.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/showtile.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/showtile.c	(revision 34490)
@@ -86,5 +86,5 @@
     graphmode.ptype = 100; /* connect pairs of points */
     graphmode.etype = 0;
-    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   }
 
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/simage.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/simage.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/simage.c	(revision 34490)
@@ -151,5 +151,5 @@
   graphmode.etype = 0;
 
-  PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, &graphmode);
+  PlotVectorTriplet (kapa, &Xvec, &Yvec, &Zvec, NULL, &graphmode);
 
   free (Xvec.elements.Flt);
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/skycat.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/skycat.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/skycat.c	(revision 34490)
@@ -100,5 +100,5 @@
     graphmode.ptype = 100; /* connect pairs of points */
     graphmode.etype = 0;
-    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
+    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
   }
 
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/include/display.h
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/include/display.h	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/include/display.h	(revision 34490)
@@ -7,8 +7,9 @@
 
 /*** kapa graph functions ***/
-int           PlotVectorSingle      PROTO((int kapa, Vector *vec, char *mode));
-int           PlotVectorPair        PROTO((int kapa, Vector *xVec, Vector *yVec, Graphdata *graphmode));
+int           PlotVectorSingle      PROTO((int kapa, Vector *vec, char *mask, char *mode));
+int           PlotVectorPair        PROTO((int kapa, Vector *xVec, Vector *yVec, char *mask, Graphdata *graphmode));
 int           PlotVectorPairErrors  PROTO((int kapa, Vector *xVec, Vector *yVec, Vector *dyValues, Graphdata *graphmode));
-int           PlotVectorTriplet     PROTO((int kapa, Vector *xVec, Vector *yVec, Vector *zValues, Graphdata *graphmode));
+
+int           PlotVectorTriplet     PROTO((int kapa, Vector *xVec, Vector *yVec, Vector *zValues, char *mask, Graphdata *graphmode));
 // int           GetGraphData          PROTO((Graphdata *data, int *kapa, char *name));
 int           GetGraph              PROTO((Graphdata *data, int *kapa, char *name));
Index: /branches/eam_branches/ipp-20120905/Ohana/src/opihi/lib.data/PlotVectors.c
===================================================================
--- /branches/eam_branches/ipp-20120905/Ohana/src/opihi/lib.data/PlotVectors.c	(revision 34489)
+++ /branches/eam_branches/ipp-20120905/Ohana/src/opihi/lib.data/PlotVectors.c	(revision 34490)
@@ -1,7 +1,7 @@
 # include "display.h"
 
-int PlotVectorSingle (int kapa, Vector *vec, char *mode) {
-
-  int i, Npts;
+int PlotVectorSingle (int kapa, Vector *vec, char *mask, char *mode) {
+
+  int i, Npts, Nout;
   float *temp;
 
@@ -9,25 +9,30 @@
   ALLOCATE (temp, float, Npts);
 
+  Nout = 0;
   if (vec->type == OPIHI_FLT) {
     opihi_flt *value = vec->elements.Flt;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
     }
   } else {
     opihi_int *value = vec->elements.Int;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
-    }
-  }
-  KapaPlotVector (kapa, Npts, temp, mode);
-
-  free (temp);
-
-  return (TRUE);
-}
-
-int PlotVectorPair (int kapa, Vector *xVec, Vector *yVec, Graphdata *graphmode) {
-
-  int i, Npts;
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
+    }
+  }
+  KapaPlotVector (kapa, Nout, temp, mode);
+
+  free (temp);
+
+  return (TRUE);
+}
+
+int PlotVectorPair (int kapa, Vector *xVec, Vector *yVec, char *mask, Graphdata *graphmode) {
+
+  int i, Npts, Nout;
   float *temp;
 
@@ -37,40 +42,49 @@
   ALLOCATE (temp, float, Npts);
 
-  KapaPrepPlot (kapa, Npts, graphmode);
-
+  Nout = 0;
   if (xVec->type == OPIHI_FLT) {
     opihi_flt *value = xVec->elements.Flt;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
     }
   } else {
     opihi_int *value = xVec->elements.Int;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
-    }
-  }
-  KapaPlotVector (kapa, Npts, temp, "x");
-
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
+    }
+  }
+  KapaPrepPlot (kapa, Nout, graphmode);
+  KapaPlotVector (kapa, Nout, temp, "x");
+
+  Nout = 0;
   if (yVec->type == OPIHI_FLT) {
     opihi_flt *value = yVec->elements.Flt;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
     }
   } else {
     opihi_int *value = yVec->elements.Int;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
-    }
-  }
-  KapaPlotVector (kapa, Npts, temp, "y");
-
-  free (temp);
-
-  return (TRUE);
-}
-
-int PlotVectorTriplet (int kapa, Vector *xVec, Vector *yVec, Vector *zVec, Graphdata *graphmode) {
-
-  int i, Npts;
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
+    }
+  }
+  KapaPlotVector (kapa, Nout, temp, "y");
+
+  free (temp);
+
+  return (TRUE);
+}
+
+int PlotVectorTriplet (int kapa, Vector *xVec, Vector *yVec, Vector *zVec, char *mask, Graphdata *graphmode) {
+
+  int i, Npts, Nout;
   float *temp;
 
@@ -81,44 +95,58 @@
   ALLOCATE (temp, float, Npts);
 
-  KapaPrepPlot (kapa, Npts, graphmode);
-
+  Nout = 0;
   if (xVec->type == OPIHI_FLT) {
     opihi_flt *value = xVec->elements.Flt;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
     }
   } else {
     opihi_int *value = xVec->elements.Int;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
-    }
-  }
-  KapaPlotVector (kapa, Npts, temp, "x");
-
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
+    }
+  }
+  KapaPrepPlot (kapa, Nout, graphmode);
+  KapaPlotVector (kapa, Nout, temp, "x");
+
+  Nout = 0;
   if (yVec->type == OPIHI_FLT) {
     opihi_flt *value = yVec->elements.Flt;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
     }
   } else {
     opihi_int *value = yVec->elements.Int;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
-    }
-  }
-  KapaPlotVector (kapa, Npts, temp, "y");
-
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
+    }
+  }
+  KapaPlotVector (kapa, Nout, temp, "y");
+
+  Nout = 0;
   if (zVec->type == OPIHI_FLT) {
     opihi_flt *value = zVec->elements.Flt;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
     }
   } else {
     opihi_int *value = zVec->elements.Int;
     for (i = 0; i < Npts; i++) {
-      temp[i] = value[i];
-    }
-  }
-  KapaPlotVector (kapa, Npts, temp, "z");
+      if (mask && mask[i]) continue;
+      temp[Nout] = value[i];
+      Nout ++;
+    }
+  }
+  KapaPlotVector (kapa, Nout, temp, "z");
 
   free (temp);
