Commit 10206 adds custom axis label support (the function
plslabelfunc, C only for now) to PLplot trunk.  Commit 10207 updates
example 19 (also C only for now) to use plslabelfunc for specialized
longitude and latitude axis labels.  The function is simplified from
what I originally proposed, based on comments from others on the list:

void plslabelfunc(void (*label_func)(PLINT, PLFLT, const char *,
PLPointer), PLPointer label_data);

where label_func arguments would be:

void label_func(PLINT axis, PLFLT value, const char *label, PLPointer data);

label_func should create a string with the desired label text (based
on the value in the "axis" argument) and set "label" to point to that
string.  "label_data" from plslabelfunc is passed to each call of
label_func as "data".  "axis" could be changed to take an enumeration
of some sort rather than #define'd constants if that would be
considered better.  For now, I have added PL_X_AXIS, PL_Y_AXIS and
PL_Z_AXIS to plplot.h with appropriate values.  Named integer
constants seem to be used in PLplot over enums, so I was going largely
by precedent in this choice.

I also added, per Steve's request, support for custom placement of the
"(x10^n)" axis scaling text.  I have not committed an example to svn
to demonstrate this, but I do have a patch for example 1 which
demonstrates this (see the attached patch).  If no custom labeling
function is provided, one can provide a struct with information on how
to position the axis multiplier text.  If others think this is worth
including this update to example 1 I will commit it.  It is a very
subtle visual change, so I didn't want to be overly invasive with
these updates.

While I am reasonably happy with the axis labeling implementation, I
am less happy with the implementation of the customized (x10^n)
multiplier positioning - it feels inelegant and inflexible to me.
Improvements, or suggestions for improvements, are welcome.

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science
diff --git a/examples/c/x01c.c b/examples/c/x01c.c
index f9b30d1..8e0dc0c 100644
--- a/examples/c/x01c.c
+++ b/examples/c/x01c.c
@@ -217,6 +217,7 @@ plot1(int do_test)
 {
   int i;
     PLFLT xmin, xmax, ymin, ymax;
+    PLLabelDefaults label_opt;
 
     for (i = 0; i < 60; i++) {
 	x[i] = xoff + xscale * (i + 1) / 60.0;
@@ -233,13 +234,20 @@ plot1(int do_test)
 	ys[i] = y[i * 10 + 3];
     }
 
+    label_opt.exp_label_disp = 0.15;
+    label_opt.exp_label_pos = -0.07;
+    label_opt.exp_label_just = 1.0;
+
 /* Set up the viewport and window using PLENV. The range in X is
  * 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
  * scaled separately (just = 0), and we just draw a labelled
  * box (axis = 0).
+ * Also enable custom placement of the exponential label.
  */
     plcol0(1);
+    plslabelfunc(NULL, &label_opt);
     plenv(xmin, xmax, ymin, ymax, 0, 0);
+    plslabelfunc(NULL, NULL);
     plcol0(2);
     pllab("(x)", "(y)", "#frPLplot Example 1 - y=x#u2");
 
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to