Index: /trunk/Ohana/src/relphot/src/plotstuff.c
===================================================================
--- /trunk/Ohana/src/relphot/src/plotstuff.c	(revision 20190)
+++ /trunk/Ohana/src/relphot/src/plotstuff.c	(revision 20191)
@@ -25,6 +25,11 @@
   sprintf (name, "gastro [%d]", N);
 
-  // XXX need to allow for KapaOpenNamed socket instead
-  Xgraph[N] = KapaOpen ("kapa", name);
+  // if -plot is supplied, the plots are shown on the screen; 
+  // otherwise, only the final plots are generated and saved without display
+  if (PLOTSTUFF) {
+    Xgraph[N] = KapaOpen ("kapa", name);
+  } else {
+    Xgraph[N] = KapaOpen ("kapa -noX", name);
+  }
 
   if (Xgraph[N] < 0) {
@@ -38,5 +43,4 @@
 
   if (Xgraph[N] == 0) return;
-
   KapaBox (Xgraph[N], graphmode);
   return;
@@ -66,4 +70,10 @@
 
   KapaClearSections (Xgraph[N]);
+
+  KapaSetLimits (Xgraph[N], graphmode);
+  KapaSetFont (Xgraph[N], "helvetica", 14);
+  KapaBox (Xgraph[N], graphmode);
+  // KapaSendLabel (Xgraph[N], "PSF Mag", KAPA_LABEL_XM);
+  // KapaSendLabel (Xgraph[N], "Ap Mag - PSF Mag", KAPA_LABEL_YM);
 
   KapaPrepPlot (Xgraph[N], Npts, graphmode);
@@ -95,8 +105,22 @@
 }
 
-void plot_list (Graphdata *graphdata, double *xlist, double *ylist, int N, char *label, char *file) {
+// plot the vector pair to a file with name defined by the varargs format
+void plot_list (Graphdata *graphdata, double *xlist, double *ylist, int N, char *label, char *format, ...) {
 
-  int i;
+  char tmp, *filename;
+  int i, Nbyte;
   StatType stats;
+  va_list argp;  
+
+  va_start (argp, format);
+  Nbyte = vsnprintf (&tmp, 0, format, argp);
+  va_end (argp);
+  if (!Nbyte) return;
+  Nbyte ++;
+
+  ALLOCATE (filename, char, Nbyte);
+  va_start (argp, format);
+  vsnprintf (filename, Nbyte, format, argp);
+  va_end (argp);
   
   stats.min = stats.max = xlist[0];
@@ -122,5 +146,5 @@
   DonePlotting (graphdata, 0);
 
-  if ((file != NULL) && SAVEPLOT) JpegPlot (graphdata, 0, file);
+  if (SAVEPLOT) JpegPlot (graphdata, 0, filename);
   if (PLOTDELAY > 500000) {
     fprintf (stdout, "press return\n"); 
@@ -129,4 +153,5 @@
     usleep (PLOTDELAY);
   }
+  free (filename);
 }
 
