Index: /branches/eam_branches/Ohana.20100407/src/kapa2/doc/mark.issues.txt
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/doc/mark.issues.txt	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/doc/mark.issues.txt	(revision 27693)
@@ -1,2 +1,4 @@
+
+
 -> The "plot" command needs to be fixed so that boundaries of contours do
 not cause it to draw excessive amounts of lines connecting unrelated
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/doc/notes.txt
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/doc/notes.txt	(revision 27693)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/doc/notes.txt	(revision 27693)
@@ -0,0 +1,8 @@
+
+2010.04.14
+
+  * one font per frame
+  * user-settable box padding
+  * user-settable label & axis-label padding
+
+  
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/include/prototypes.h
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/include/prototypes.h	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/include/prototypes.h	(revision 27693)
@@ -39,5 +39,5 @@
 void          DrawXErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
 void          DrawYErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
-void	      DrawTick		  PROTO((int fx, int fy, int dfx, int dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));
+void	      DrawTick		  PROTO((Axis *axis, int P, double value, int IsLabel, int IsMajor, int naxis));
 void	      AxisTickScale	  PROTO((Axis *axis, double *major, double *minor));
 
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/include/structures.h
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/include/structures.h	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/include/structures.h	(revision 27693)
@@ -137,4 +137,5 @@
   double min, max;
   char isaxis, areticks, islabel, islog;
+  double pad, labelPad, ticktextPad;
   double fx, dfx, fy, dfy;  /* axis location on graphic */
   double lweight;
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/DrawFrame.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/DrawFrame.c	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/DrawFrame.c	(revision 27693)
@@ -8,5 +8,5 @@
   
   int i, fx, fy, dfx, dfy, P, IsLabel, IsMajor;
-  double range, major, minor, first, next, lweight;
+  double range, major, minor, first, value, lweight;
 
   graphic = GetGraphic();
@@ -62,15 +62,15 @@
 	first -= minor;
       }
-      for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
+      for (value = first; ((range > 0) && (value <= graph[0].axis[i].max)) || ((range < 0) && (value >= graph[0].axis[i].max));) {
 	IsMajor = FALSE;
-	IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major));
-	IsMajor |= (fabs((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
-	IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
+	IsMajor |= (fabs((int)(value/major) - (value/major)) < 0.5*(minor/major));
+	IsMajor |= (fabs((int)((value + 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));
+	IsMajor |= (fabs ((int)((value - 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));
 	IsLabel = (IsMajor && graph[0].axis[i].islabel);
-	DrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i);
+	DrawTick (&graph[0].axis[i], P, value, IsLabel, IsMajor, i);
 	if (range > 0) 
-	  next += minor;
+	  value += minor;
 	else 
-	  next -= minor;
+	  value -= minor;
       }
     }
@@ -78,11 +78,17 @@
 }
 
-void DrawTick (int fx, int fy, int dfx, int dfy, 
-	       int P, double min, double max, 
-	       double value, int IsLabel, int IsMajor, int naxis) {
+void DrawTick (Axis *axis, int P, double value, int IsLabel, int IsMajor, int naxis) {
   
   int x, y, dx, dy, pos, dir, fontsize;
-  double size, n;
+  double size, n, pad;
   char string[64], *fontname;
+
+  int fx  = axis->fx;
+  int fy  = axis->fy;
+  int dfx = axis->dfx;
+  int dfy = axis->dfy;
+
+  double min = axis->min;
+  double max = axis->max;
 
   if (IsMajor) { 
@@ -96,6 +102,5 @@
   y = fy + (value-min)*dfy/(max - min);
 
-  dir = +1;
-  if ((naxis == 0) || (naxis == 1)) dir *= -1;
+  dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1;
   dx = dir*size*dfy*n;	
   dy = dir*size*dfx*n;
@@ -103,20 +108,16 @@
   DrawLine (x, y, dx, dy);
 
-# ifdef IN_AND_OUT_TICKS
-# define GAP 0.03
-# else
-# define GAP 0.01
-# endif
-
   if (IsLabel) {
     fontname = GetRotFont (&fontsize);
     pos = 0;
     
+    pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
+    
     /* temporarily assume rectilinear axes */
-    if (naxis == 0) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 1; }
-    if (naxis == 2) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 7; }
+    if (naxis == 0) { dx = 0; dy = +pad; pos = 1; }
+    if (naxis == 2) { dx = 0; dy = -pad; pos = 7; }
 
-    if (naxis == 1) { dy = 0; dx = -(0.8*fontsize + 1); pos = 3; }
-    if (naxis == 3) { dy = 0; dx = +(0.8*fontsize + 1); pos = 5; }
+    if (naxis == 1) { dy = 0; dx = -pad; pos = 3; }
+    if (naxis == 3) { dy = 0; dx = +pad; pos = 5; }
 
     x = fx + (value-min)*dfx/(max - min) + dx;
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/Graphs.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/Graphs.c	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/Graphs.c	(revision 27693)
@@ -13,9 +13,12 @@
     graph[0].axis[i].min = 0.0;
     graph[0].axis[i].max = 1.0;
-    graph[0].axis[i].isaxis = FALSE;
-    graph[0].axis[i].areticks = FALSE;
-    graph[0].axis[i].islabel = FALSE;
+    graph[0].axis[i].isaxis = TRUE;
+    graph[0].axis[i].areticks = TRUE;
+    graph[0].axis[i].islabel = (i < 2);
     graph[0].axis[i].lweight = 0.0;
     graph[0].axis[i].color = 0;
+    graph[0].axis[i].ticktextPad = NAN;
+    graph[0].axis[i].labelPad = NAN;
+    graph[0].axis[i].pad = NAN;
   }    
   for (i = 0; i < 8; i++) {
@@ -80,9 +83,9 @@
     
   /* reset axes and labels */
-  for (i = 0; i < 4; i++) {
-    graph[0].axis[i].isaxis = FALSE;
-    graph[0].axis[i].islabel = FALSE;
-    graph[0].axis[i].areticks = FALSE;
-  }
+  // for (i = 0; i < 4; i++) {
+  //   graph[0].axis[i].isaxis = FALSE;
+  //   graph[0].axis[i].islabel = FALSE;
+  //   graph[0].axis[i].areticks = FALSE;
+  // }
   for (i = 0; i < 8; i++) {
     strcpy (graph[0].label[i].text, "");
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/LoadFrame.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/LoadFrame.c	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/LoadFrame.c	(revision 27693)
@@ -5,5 +5,5 @@
   int i, color;
   char Axis[16], Labels[16], Ticks[16];
-  double lweight;
+  double lweight, ticktextPad, labelPad, padXm, padXp, padYm, padYp;
   Section *section;
   KapaGraphWidget *graph;
@@ -28,4 +28,10 @@
   color = MAX (0, MIN (15, color));
 
+  KiiScanMessage (sock, "%lf %lf %lf %lf %lf %lf", &ticktextPad, &labelPad, &padXm, &padXp, &padYm, &padYp);
+  graph[0].axis[0].pad = padXm;
+  graph[0].axis[1].pad = padYm;
+  graph[0].axis[2].pad = padXp;
+  graph[0].axis[3].pad = padYp;
+
   KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks);
 
@@ -33,4 +39,7 @@
     graph[0].axis[i].lweight = lweight;
     graph[0].axis[i].color = color;
+
+    graph[0].axis[i].ticktextPad = ticktextPad;
+    graph[0].axis[i].labelPad = labelPad;
 
     switch (Axis[i]) {
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphData.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphData.c	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphData.c	(revision 27693)
@@ -28,4 +28,12 @@
 		  &graph[0].data.lweight, 
 		  &graph[0].data.size);
+
+  KiiScanMessage (sock, "%lf %lf %lf %lf %lf %lf", 
+		  &graph[0].data.ticktextPad, 
+		  &graph[0].data.labelPad, 
+		  &graph[0].data.padXm, 
+		  &graph[0].data.padXp, 
+		  &graph[0].data.padYm, 
+		  &graph[0].data.padYp);
 
   KiiScanMessage (sock, "%lf %lf %lf %lf", 
@@ -96,4 +104,12 @@
 		  graph[0].data.lweight, graph[0].data.size);
 
+  KiiSendMessage (sock, "%g %g %g %g %g %g", 
+		  graph[0].data.ticktextPad, 
+		  graph[0].data.labelPad, 
+		  graph[0].data.padXm, 
+		  graph[0].data.padXp, 
+		  graph[0].data.padYm, 
+		  graph[0].data.padYp);
+
   KiiSendMessage (sock, "%g %g %g %g", 
 		  graph[0].data.xmin, graph[0].data.xmax, 
Index: /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphSize.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphSize.c	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphSize.c	(revision 27693)
@@ -8,6 +8,7 @@
   int fontsize, bump, Nc;
   int textpad, textdY, WdY; 
-  double PADx, PADy, Dx, Dy;
-  double PXm, PXp, PYm, PYp;
+  double padXm, padXp, padYm, padYp;
+  double minPADx, maxPADx, minPADy, maxPADy;
+  double minPAD, maxPAD;
   double X0, Y0, dX, dY;
   char string[64], *fontname;
@@ -22,20 +23,36 @@
   fontname = GetRotFont (&fontsize);
 
-  PADx = MAX (graphic->dx / 20.0, fontsize);
-  PADy = MAX (graphic->dy / 20.0, fontsize);
-  Dx = graphic->dx - 2*PADx;
-  Dy = graphic->dy - 2*PADy;
+  minPADx = fontsize;
+  minPADy = fontsize;
+  maxPADx = 5*fontsize;
+  maxPADy = 5*fontsize;
 
-  /* each graph has a padding PXm, PXp, PYm, PYp */
-  PXm = (graph[0].axis[1].islabel) ? 4*fontsize : 0;
-  PXp = (graph[0].axis[3].islabel) ? 4*fontsize : 0;
-  PYm = (graph[0].axis[0].islabel) ? 4*fontsize : 0;
-  PYp = (graph[0].axis[2].islabel) ? 4*fontsize : 0;
- 
+  // padXm : padding below x-axis, padYp : padding to right of y-axis, etc
+  if (isnan(graph[0].axis[0].pad)) {
+      padXm = graph[0].axis[0].islabel ? maxPADx : minPADx;
+  } else {
+      padXm = graph[0].axis[0].pad * fontsize;
+  }
+  if (isnan(graph[0].axis[1].pad)) {
+      padYm = graph[0].axis[1].islabel ? maxPADx : minPADx;
+  } else {
+      padYm = graph[0].axis[1].pad * fontsize;
+  }
+  if (isnan(graph[0].axis[2].pad)) {
+      padXp = graph[0].axis[2].islabel ? maxPADx : minPADx;
+  } else {
+      padXp = graph[0].axis[2].pad * fontsize;
+  }
+  if (isnan(graph[0].axis[3].pad)) {
+      padYp = graph[0].axis[3].islabel ? maxPADx : minPADx;
+  } else {
+      padYp = graph[0].axis[3].pad * fontsize;
+  }
+
   /* basic size of the graph in Xwindow coordinates */
-  X0 = PADx + PXm + (Dx * section[0].x);
-  Y0 = PADy + PYm + (Dy * section[0].y);
-  dX = (Dx * section[0].dx) - PXp - PXm;
-  dY = (Dy * section[0].dy) - PYp - PYm;
+  X0 = graphic[0].dx * section[0].x + padYm;
+  Y0 = graphic[0].dy * section[0].y + padXm;
+  dX = graphic[0].dx * section[0].dx - padYm - padYp;
+  dY = graphic[0].dy * section[0].dy - padXm - padXp;
 
   // if we are tied to an image, make mods as needed
@@ -47,9 +64,9 @@
     switch (section->image->location) {
       case 1:
-	Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y
+	Y0 = graphic[0].dy * section[0].y  + 2*PAD1 + WdY + 2; // tied to image in Y
 	dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1;
 	break;
       case 3:
-	dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - PADy - PYm;
+	dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - padYm - padYp;
 	break;
       case 2:
@@ -58,5 +75,5 @@
 	break;
       case 4:
-	dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - PADx - PXm;
+	dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - padXm - padXp;
 	break;
     }
@@ -85,14 +102,22 @@
   graph[0].axis[3].dfy = -dY;
 
-  PADx = 0.8*fontsize + 2;
-  PADy = 3.0*fontsize + 4;
+  minPAD = 0.8*fontsize + 2;
+  maxPAD = 3.0*fontsize + 4;
 
   /* define locations of axis labels */
   graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx;
-  bump = (graph[0].axis[0].islabel) ? PADy : PADx;
+  if (isnan(graph[0].axis[0].labelPad)) {
+      bump = (graph[0].axis[0].islabel) ? maxPAD : minPAD;
+  } else {
+      bump = graph[0].axis[0].labelPad * fontsize;
+  }
   graph[0].label[LABELX0].y = graph[0].axis[0].fy + bump;
 
   graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx;
-  bump = (graph[0].axis[2].islabel) ? PADy : PADx;
+  if (isnan(graph[0].axis[2].labelPad)) {
+      bump = (graph[0].axis[2].islabel) ? maxPAD : minPAD;
+  } else {
+      bump = graph[0].axis[2].labelPad * fontsize;
+  }
   graph[0].label[LABELX1].y = graph[0].axis[2].fy - bump;
 
@@ -104,5 +129,9 @@
 
   graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy;
-  bump = (graph[0].axis[1].islabel) ? (0.8*Nc*fontsize + 1) : PADx;
+  if (isnan(graph[0].axis[1].labelPad)) {
+      bump = (graph[0].axis[1].islabel) ? (0.8*Nc*fontsize + 1) : minPAD;
+  } else {
+      bump = graph[0].axis[1].labelPad * fontsize;
+  }
   graph[0].label[LABELY0].x = graph[0].axis[1].fx - bump;
 
@@ -113,17 +142,20 @@
 
   graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy;
-  bump = (graph[0].axis[3].islabel) ? (0.8*Nc*fontsize + 1) : PADx;
+  if (isnan(graph[0].axis[3].labelPad)) {
+      bump = (graph[0].axis[3].islabel) ? (0.8*Nc*fontsize + 1) : minPAD;
+  } else {
+      bump = graph[0].axis[3].labelPad * fontsize;
+  }
   graph[0].label[LABELY1].x = graph[0].axis[3].fx + bump;
   
   /* these are wrong and have to be adjusted to sit in the corners */
 
-  graph[0].label[LABELUL].x = graph[0].axis[2].fx - PADx;
-  graph[0].label[LABELUL].y = graph[0].axis[2].fy - PADx;
-  graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx + PADx;
-  graph[0].label[LABELUR].y = graph[0].axis[2].fy - PADx;
-  graph[0].label[LABELLL].x = graph[0].axis[0].fx - PADx;
-  graph[0].label[LABELLL].y = graph[0].axis[0].fy + PADx;
-  graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx + PADx;
-  graph[0].label[LABELLR].y = graph[0].axis[0].fy + PADx;
-
+  graph[0].label[LABELUL].x = graph[0].axis[2].fx;
+  graph[0].label[LABELUL].y = graph[0].axis[2].fy - minPAD;
+  graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx;
+  graph[0].label[LABELUR].y = graph[0].axis[2].fy - minPAD;
+  graph[0].label[LABELLL].x = graph[0].axis[0].fx;
+  graph[0].label[LABELLL].y = graph[0].axis[0].fy + minPAD;
+  graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx;
+  graph[0].label[LABELLR].y = graph[0].axis[0].fy + minPAD;
 }
Index: /branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h	(revision 27693)
@@ -79,4 +79,6 @@
   int style, ptype, ltype, etype, ebar, color;
   double lweight, size;
+  double ticktextPad, labelPad;
+  double padXm, padXp, padYm, padYp;
   Coords coords;
   int flipeast, flipnorth;
Index: /branches/eam_branches/Ohana.20100407/src/libkapa/src/KapaWindow.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/libkapa/src/KapaWindow.c	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/libkapa/src/KapaWindow.c	(revision 27693)
@@ -42,4 +42,6 @@
 
   KiiSendMessage (fd, "%lf %d", graphdata[0].lweight, graphdata[0].color);
+
+  KiiSendMessage (fd, "%lf %lf %lf %lf %lf %lf", graphdata[0].ticktextPad, graphdata[0].labelPad, graphdata[0].padXm, graphdata[0].padXp, graphdata[0].padYm, graphdata[0].padYp);
 
   KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks);
@@ -140,4 +142,10 @@
 		  data[0].lweight, data[0].size);
 
+  KiiSendMessage (fd, "%g %g %g %g %g %g", 
+		  data[0].ticktextPad, data[0].labelPad, 
+		  data[0].padXm, data[0].padXp, 
+		  data[0].padYm, data[0].padYp);
+
+
   KiiSendMessage (fd, "%g %g %g %g", 
 		  data[0].xmin, data[0].xmax, 
@@ -175,4 +183,9 @@
 		  &data[0].etype, &data[0].ebar, &data[0].color, 
 		  &data[0].lweight, &data[0].size);
+
+  KiiScanMessage (fd, "%lf %lf %lf %lf %lf %lf", 
+		  &data[0].ticktextPad, &data[0].labelPad, 
+		  &data[0].padXm, &data[0].padXp, 
+		  &data[0].padYm, &data[0].padYp);
 
   KiiScanMessage (fd, "%lf %lf %lf %lf", 
Index: /branches/eam_branches/Ohana.20100407/src/opihi/cmd.data/box.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/opihi/cmd.data/box.c	(revision 27692)
+++ /branches/eam_branches/Ohana.20100407/src/opihi/cmd.data/box.c	(revision 27693)
@@ -25,5 +25,5 @@
   } 
 
-  graphmode.lweight = 1;
+  // graphmode.lweight = 1;
   if ((N = get_argument (argc, argv, "-lw"))) {
     remove_argument (N, &argc, argv);
@@ -32,5 +32,5 @@
   }
 
-  graphmode.color = KapaColorByName ("black");
+  // graphmode.color = KapaColorByName ("black");
   if ((N = get_argument (argc, argv, "-c"))) {
     remove_argument (N, &argc, argv);
@@ -40,5 +40,5 @@
   }
 
-  strcpy (graphmode.ticks, "2222");
+  // strcpy (graphmode.ticks, "2222");
   if ((N = get_argument (argc, argv, "-ticks"))) {
     remove_argument (N, &argc, argv);
@@ -51,5 +51,5 @@
   }
   
-  strcpy (graphmode.labels, "2222");
+  // strcpy (graphmode.labels, "2222");
   if ((N = get_argument (argc, argv, "-labels"))) {
     remove_argument (N, &argc, argv);
@@ -62,5 +62,5 @@
   }
 
-  strcpy (graphmode.axis, "2222");
+  // strcpy (graphmode.axis, "2222");
   if ((N = get_argument (argc, argv, "-axis"))) {
     remove_argument (N, &argc, argv);
@@ -71,4 +71,37 @@
       if ((graphmode.axis[i] != '0') && (graphmode.axis[i] != '1') && (graphmode.axis[i] != '2')) { goto usage; }
     }
+  }
+
+  if ((N = get_argument (argc, argv, "-tickpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.ticktextPad = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "-labelpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.labelPad = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "-xpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padXm = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "+xpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padXp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-ypad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padYm = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "+ypad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padYp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
   }
 
Index: anches/eam_branches/Ohana.20100407/src/opihi/lib.data/open_graph.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/opihi/lib.data/open_graph.c	(revision 27692)
+++ 	(revision )
@@ -1,176 +1,0 @@
-# include "display.h"
-# include "shell.h"
-# define DEBUG 0
-
-/* we have space for several kapa windows */
-# define NXGRAPH 5
-
-static int       Active;
-static int       Xgraph[NXGRAPH];  
-static Graphdata graphdata[NXGRAPH];
-
-void QuitGraph () {
-
-  int i;
-  
-  for (i = 0; i < NXGRAPH; i++) {
-    KiiClose (Xgraph[i]);
-  }
-}
-
-void InitGraph () {
-
-  int i;
-
-  Active = 0;
-  for (i = 0; i < NXGRAPH; i++) {
-    Xgraph[i] = -1;
-
-    graphdata[i].xmin = graphdata[i].ymin = 0.0;
-    graphdata[i].xmax = graphdata[i].ymax = 1.0;
-    graphdata[i].style = graphdata[i].ptype = 0;
-    graphdata[i].ltype = graphdata[i].color = 0;
-    graphdata[i].etype = graphdata[i].ebar = 0;
-    graphdata[i].lweight = graphdata[i].size = 1.0;
-    
-    graphdata[i].coords.pc1_1 = graphdata[i].coords.pc2_2 = 1.0;
-    graphdata[i].coords.pc1_2 = graphdata[i].coords.pc2_1 = 0.0;
-    strcpy (graphdata[i].coords.ctype, "RA---LIN");
-    graphdata[i].coords.crval1 = 0.0;
-    graphdata[i].coords.crval2 = 0.0;
-    graphdata[i].coords.crpix1 = 0.0;
-    graphdata[i].coords.crpix2 = 0.0;
-    graphdata[i].coords.cdelt1 = graphdata[i].coords.cdelt2 = 1.0;
-    graphdata[i].flipeast = TRUE;
-    graphdata[i].flipnorth = FALSE;
-    strcpy (graphdata[i].axis, "2222");
-    strcpy (graphdata[i].ticks, "2222");
-    strcpy (graphdata[i].labels, "2222");
-  }
-}
-
-/* set SIGPIPE to this function to close cleanly */ 
-void XGraphDead (int input) {
-  signal (SIGPIPE, XGraphDead);
-  gprint (GP_ERR, "kapa is dead, must restart\n");
-  Xgraph[Active] = -1;
-}
-
-/** start socketed connection */
-int open_graph (int N) {
-
-  int fd;
-  char *kapa_exec, name[16];
-  
-  kapa_exec = get_variable ("KAPA");
-  if (kapa_exec == (char *) NULL) {
-    gprint (GP_ERR, "variable KAPA not found\n");
-    return (FALSE);
-  }
-
-  snprintf (name, 16, "[%d]", N);
-  fd = KiiOpen (kapa_exec, name);
-  free (kapa_exec);
-
-  if (fd < 0) {
-    gprint (GP_ERR, "error starting kapa\n");
-    return (FALSE);
-  } 
-
-  Xgraph[N] = fd;
-  return (TRUE);
-}
-
-int close_graph (int N) {
-
-  if (N <  0) return (FALSE);
-  if (N >= NXGRAPH) return (FALSE);
-
-  KiiClose (Xgraph[N]); 
-  Xgraph[N] = -1;
-  return (TRUE);
-}
-
-/* return pointers for current Xgraph, set if desired, test, open if needed */
-int GetGraph (Graphdata *data, int *socket, int *N) {
-
-  int i, n;
-  char buffer[70];
-
-  SetImageDevice (FALSE);
-  if (N == (int *) NULL) {
-    n = Active;
-  } else {
-    if (*N >= NXGRAPH) {
-      gprint (GP_ERR, "invalid Xgraph window %d\n", *N); 
-      return (FALSE);
-    }
-    if (*N < 0) {
-      *N = n = Active;
-    } else {
-      Active = n = *N;
-    }
-  }
-  
-  /* test Xgraph[0], flush junk from pipe */
-  signal (SIGPIPE, XGraphDead);
-  fcntl (Xgraph[n], F_SETFL,  O_NONBLOCK); 
-  for (i = 0; (read (Xgraph[n], buffer, 64) > 0) && (i < 20); i++);
-  fcntl (Xgraph[n], F_SETFL, !O_NONBLOCK); 
-  
-  if (Xgraph[n] < 1) {
-    if (!open_graph(n)) {
-      return (FALSE);
-    }
-  }
-
-  if (data != (Graphdata *) NULL) *data  = graphdata[n];
-  if (socket != (int *) NULL) *socket = Xgraph[n];
-
-  return (TRUE);
-
-}
-
-/* return pointers for given Xgraph, don't set or open */
-int GetGraphData (Graphdata *data, int *sock, int *N) {
-
-  int n;
-
-  if (N == (int *) NULL) {
-    n = Active;
-  } else {
-    if (*N >= NXGRAPH) {
-      gprint (GP_ERR, "invalid Xgraph window %d\n", *N); 
-      return (FALSE);
-    }
-    if (*N < 0) {
-      n = Active;
-    } else {
-      n = *N;
-    }
-  }
-  
-  if (data != (Graphdata *) NULL) *data  = graphdata[n];
-  if (sock != (int *) NULL) *sock = Xgraph[n];
-
-  return (TRUE);
-
-}
-
-/* assign given values to current Xgraph */
-void SetGraph (Graphdata data) {
-  graphdata[Active] = data;
-}
-
-/** internal tracking of current active device type **/
-
-static int       IsImage = FALSE;
-
-int GetCurrentDevice () {
-  return (IsImage);
-}
-
-void SetImageDevice (int state) {
-  IsImage = state;
-}
-
Index: anches/eam_branches/Ohana.20100407/src/opihi/lib.data/open_image.c
===================================================================
--- /branches/eam_branches/Ohana.20100407/src/opihi/lib.data/open_image.c	(revision 27692)
+++ 	(revision )
@@ -1,133 +1,0 @@
-# include "display.h"
-# include "shell.h"
-# define DEBUG 0
-
-/* we have space for several kii windows */
-# define NXIMAGE 5
-
-static int       Active;
-static int       Ximage[NXIMAGE];  
-static char      Ximbuffer[NXIMAGE][512];
-static double    Xzero[NXIMAGE];
-static double    Xrange[NXIMAGE];
-
-void QuitImage () {
-
-  int i;
-  
-  for (i = 0; i < NXIMAGE; i++) {
-    KiiClose (Ximage[i]);
-  }
-}
-
-void InitImage () {
-
-  int i;
-
-  Active = 0;
-  for (i = 0; i < NXIMAGE; i++) {
-    Ximage[i] = -1;
-    Xzero[i] = 0;
-    Xrange[i] = 1024;
-    strcpy (Ximbuffer[i], "none");
-  }
-}
-
-/* set SIGPIPE to this function to close cleanly */ 
-void XImageDead (int input) {
-  signal (SIGPIPE, XImageDead);
-  gprint (GP_ERR, "kii is dead, must restart\n");
-  Ximage[Active] = -1;
-}
-
-/** start socketed connection */
-int open_image (int N) {
-
-  int fd;
-  char *kii_exec, name[16];
-
-  kii_exec = get_variable ("KII");
-  if (kii_exec == (char *) NULL) {
-    gprint (GP_ERR, "variable KII not found\n");
-    return (FALSE);
-  }
-
-  snprintf (name, 16, "[%d]", N);
-  fd = KiiOpen (kii_exec, name);
-  free (kii_exec);
-
-  if (fd < 0) {
-    gprint (GP_ERR, "error starting kii\n");
-    return (FALSE);
-  } 
-
-  Ximage[N] = fd;
-  return (TRUE);
-}
-
-int close_image (int N) {
-
-  if (N <  0) return (FALSE);
-  if (N >= NXIMAGE) return (FALSE);
-
-  KiiClose (Ximage[N]); 
-  Ximage[N] = -1;
-  return (TRUE);
-}
-
-/* return pointers for current Ximage, set if desired, test, open if needed */
-int GetImage (int *socket, int *N) {
-
-  int i, n;
-  char buffer[70];
-
-  SetImageDevice (TRUE);
-  if (N == (int *) NULL) {
-    n = Active;
-  } else {
-    if (*N >= NXIMAGE) {
-      gprint (GP_ERR, "invalid Ximage window %d\n", *N); 
-      return (FALSE);
-    }
-    if (*N < 0) {
-      *N = n = Active;
-    } else {
-      Active = n = *N;
-    }
-  }
-  
-  /* test Ximage[0], flush junk from pipe */
-  signal (SIGPIPE, XImageDead);
-  fcntl (Ximage[n], F_SETFL,  O_NONBLOCK); 
-  for (i = 0; (read (Ximage[n], buffer, 64) > 0) && (i < 20); i++);
-  fcntl (Ximage[n], F_SETFL, !O_NONBLOCK); 
-  
-  if (Ximage[n] < 1) {
-    if (!open_image(n)) {
-      return (FALSE);
-    }
-  }
-
-  if (socket != (int *) NULL) *socket = Ximage[n];
-
-  return (TRUE);
-
-}
-
-void SetImageName (char *name) {
-  strcpy (Ximbuffer[Active], name);
-}
-
-char *GetImageName () {
-  return (Ximbuffer[Active]);
-}
- 
-// leave this information on kapa, request when needed? 
-void SetImageScale (double zero, double range) {
-  Xzero[Active] = zero;
-  Xrange[Active] = range;
-}
-void GetImageScale (double *zero, double *range) {
-  *zero = Xzero[Active];
-  *range = Xrange[Active];
-}
