Index: trunk/Ohana/src/opihi/cmd.astro/cgrid.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 40418)
+++ trunk/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 40419)
@@ -95,4 +95,38 @@
   }
 
+  int JustifyRA = 5;
+  double JustifyDEC = 5;
+  if ((N = get_argument (argc, argv, "-justify-ra"))) {
+    remove_argument (N, &argc, argv);
+    JustifyRA = atoi (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-justify-dec"))) {
+    remove_argument (N, &argc, argv);
+    JustifyDEC = atoi (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  double LabelRA = NAN;
+  double LabelDEC = NAN;
+  if ((N = get_argument (argc, argv, "-label-ra"))) {
+    remove_argument (N, &argc, argv);
+    LabelRA = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-label-dec"))) {
+    remove_argument (N, &argc, argv);
+    LabelDEC = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  int LabelColor = KapaColorByName ("black");
+  if ((N = get_argument (argc, argv, "-label-color"))) {
+    remove_argument (N, &argc, argv);
+    LabelColor = KapaColorByName (argv[N]);
+    if (LabelColor == -1) return (FALSE);
+    remove_argument (N, &argc, argv);
+  }
+
   if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
 
@@ -196,10 +230,12 @@
   if (Labels) { 
     char line[16], format[8];
-    double xt, yt, dx, dy, frac;
-    dx = +0.01 * (graphmode.xmax - graphmode.xmin);
-    dy = -0.02 * (graphmode.ymax - graphmode.ymin);
-
+    double xt, yt, frac;
+    // dx = +0.01 * (graphmode.xmax - graphmode.xmin);
+    // dy = -0.02 * (graphmode.ymax - graphmode.ymin);
+
+    if (isnan(LabelRA)) LabelRA = graphmode.coords.crval1;
+    if (isnan(LabelDEC)) LabelDEC = graphmode.coords.crval2;
     for (r = firstRA; r <= graphmode.coords.crval1 + 180.0; r += minorRA) {
-      status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords);
+      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
       if (!status) continue;
       if (xt < graphmode.xmin) continue;
@@ -212,14 +248,15 @@
       }
       if (frac <= 0.0) frac = 0.0;
-      snprintf (format, 8, "%%.%df", (int) frac);
       if (RAbyHour) {
+	snprintf (format, 8, "%%.%df^h", (int) frac);
 	snprintf (line, 16, format, r / 15.0);
       } else {
+	snprintf (format, 8, "%%.%df^o", (int) frac);
 	snprintf (line, 16, format, r);
       }
-      KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
+      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyRA, LabelColor);
     }
     for (r = firstRA; r >= graphmode.coords.crval1 - 180.0; r -= minorRA) {
-      status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords);
+      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
       if (!status) continue;
       if (xt < graphmode.xmin) continue;
@@ -232,14 +269,15 @@
       }
       if (frac <= 0.0) frac = 0.0;
-      snprintf (format, 8, "%%.%df", (int) frac);
       if (RAbyHour) {
+	snprintf (format, 8, "%%.%df^h", (int) frac);
 	snprintf (line, 16, format, r / 15.0);
       } else {
+	snprintf (format, 8, "%%.%df^o", (int) frac);
 	snprintf (line, 16, format, r);
       }
-      KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
+      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyRA, LabelColor);
     }
     for (d = firstDEC; d <= graphmode.coords.crval2 + 90.0; d += minorDEC) {
-      status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords);
+      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
       if (!status) continue;
       if (xt < graphmode.xmin) continue;
@@ -252,10 +290,10 @@
       }
       if (frac <= 0.0) frac = 0.0;
-      snprintf (format, 8, "%%.%df", (int) frac);
+      snprintf (format, 8, "%%.%df^o", (int) frac);
       snprintf (line, 16, format, d);
-      KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
+      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyDEC, LabelColor);
     }
     for (d = firstDEC; d >= graphmode.coords.crval2 - 90.0; d -= minorDEC) {
-      status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords);
+      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
       if (!status) continue;
       if (xt < graphmode.xmin) continue;
@@ -268,7 +306,7 @@
       }
       if (frac <= 0.0) frac = 0.0;
-      snprintf (format, 8, "%%.%df", (int) frac);
+      snprintf (format, 8, "%%.%df^o", (int) frac);
       snprintf (line, 16, format, d);
-      KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
+      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyDEC, LabelColor);
     }
   }
Index: trunk/Ohana/src/opihi/cmd.data/textline.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/textline.c	(revision 40418)
+++ trunk/Ohana/src/opihi/cmd.data/textline.c	(revision 40419)
@@ -6,8 +6,26 @@
   char name[64];
   double x, y, angle;
-  int kapa;
   Graphdata graphmode;
 
-  if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
+  // if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
+
+  // Using only these style_args options
+  char *kapaName = NULL;
+  int kapa = -1;
+  if ((N = get_argument (argc, argv, "-n"))) {
+    remove_argument (N, &argc, argv);
+    kapaName = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!GetGraph (&graphmode, &kapa, kapaName)) return (FALSE);
+  FREE (kapaName);
+
+  int color = KapaColorByName ("black");
+  if ((N = get_argument (argc, argv, "-c"))) {
+    remove_argument (N, &argc, argv);
+    color = KapaColorByName (argv[N]);
+    if (color == -1) return (FALSE);
+    remove_argument (N, &argc, argv);
+  }
 
   if ((N = get_argument (argc, argv, "-fn"))) {
@@ -34,6 +52,13 @@
   } 
 
+  int justify = 5; // default
+  if ((N = get_argument (argc, argv, "-justify"))) {
+    remove_argument (N, &argc, argv);
+    justify = atoi (argv[N]);
+    remove_argument (N, &argc, argv);
+  } 
+
   if (argc != 4) {
-    gprint (GP_ERR, "USAGE: text x y (line) [-fn (font) size] [-rot angle]\n");
+    gprint (GP_ERR, "USAGE: text x y (line) [-fn (font) size] [-rot angle] [-justify N]\n");
     return (FALSE);
   }
@@ -52,5 +77,5 @@
   }    
 
-  KapaSendTextline (kapa, argv[3], x, y, angle);
+  KapaSendTextline (kapa, argv[3], x, y, angle, justify, color);
   return (TRUE);
 }
Index: trunk/Ohana/src/opihi/dvo/fitcolors.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/fitcolors.c	(revision 40418)
+++ trunk/Ohana/src/opihi/dvo/fitcolors.c	(revision 40419)
@@ -47,4 +47,6 @@
   if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;
   if (!SetPhotSelections (&argc, argv, 4)) goto usage;
+
+  int textcolor = KapaColorByName ("black");
 
   // range for valid data points (exclude extreme outliers)
@@ -324,7 +326,7 @@
 	KapaSetFont (kapa, "helvetica", 8);
 	sprintf (label, "%s", code[0][0].name);
-	KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0);
+	KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0, textcolor);
 	sprintf (label, "%s", code[1][0].name);
-	KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0);
+	KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0, textcolor);
 	KapaSetFont (kapa, "helvetica", 14);
 
