Index: trunk/Ohana/src/opihi/cmd.astro/cgrid.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/cgrid.c	(revision 40165)
+++ 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);
     }
   }
