Hez,

This would seem to address everything except what I started this thread to 
query, namely more control over the placement of the separate exponent label 
when scientific notation is used for labelling. Looking a bit into the code, 
the placement of this string is hard-wired into the label_box{} routine in 
plbox.c, e.g.:

            sprintf(string, "(x10#u%d#d)", (int) yscale);
            offset = 0.02;
            height = 2.0;
            if (lny) {
                pos = 0.0 - offset;
                plmtex("t", height, pos, 1.0, string);
            }

What I was hoping to do was to allow control  these inputs to plmtext, e.g., to 
allow us to:

Place the string at some other height from the acis
Place the string at some other pos along the axis
[I guess control the justification]
Control, independent of the orientation of the numeric labels the orientation 
(e.g., "t" or "tv") of string

One way to do this I guess would be to hold all these parameters in PLStream, 
from which label_box could get them, together with a flag indicating if the 
default values should be used instead. This would then require a new api 
routine to set these values, e.g.,

plsexppos(axis, orient, height, pos, just, usedefault)

where axis is one of x,y, or z (PLStream would need separate entries for all 
three as the user can't reset them inbetween drawing the different axes from a 
single call to plbox) and the rest of the entries are self-explanatory and 
match those of plmtex. [I haven't looked at the 3d routines to see what needs 
to be done for the z-axis.]

I could imagine an option to suppress the exponent altogether and simply return 
the appropriate string, so that the user could pass it directly to plmtex 
him/herself or, better I think, embed it in the label string - i.e., construct 
"Temperture (x10#u6#d K)". However, this is extremely dangerous as it relies on 
the user to do this, otherwise his/her plot is incorrectly labelled. I guess it 
would be straightforward for a user to specify the same position for both the 
axis label and exponent, but with one left-justified and the other 
right-justified and, with only a small tweak, create the same effect in a way 
that was less dangerous for the innocent user.

Since you'll be digging into this bit of code anyway, and since you know your 
way 'round the plplot code and practices much better than I, perhaps you could 
have a go at this at the same time as you're implementing your generalised 
labelling routines?

Cheers
Steve



________________________________________
From: plplot-devel-boun...@lists.sourceforge.net 
[plplot-devel-boun...@lists.sourceforge.net] On Behalf Of Hezekiah M. Carty 
[hca...@atmos.umd.edu]
Sent: 27 April 2009 18:50
To: Jonathan Woithe
Cc: PLplot development list; Hazen Babcock
Subject: Re: [Plplot-devel] control position of floating point label

On Sun, Apr 26, 2009 at 11:51 PM, Jonathan Woithe
<jwoi...@physics.adelaide.edu.au> wrote:
> Hi Hez
>
>> > I suggest you go ahead and implement any improvement you would like to see
>> > in PLplot axis scaling. Of course, be sure and test such improvements for
>> > all anticipated QSAS axis scaling needs.
>>
>> Would it be considered reasonable to some form of user-customizable
>> axis labeling API in PLplot by providing callbacks similar to the pltr
>> functions used by plcont and friends?  The axis labeling code could
>> remain mostly as-is.  However, when a custom labeling function is
>> defined, rather than rendering the text which matches the actual
>> number at a given axis location, that number would be passed to the
>> user-provided function.  This function would return a string with the
>> appropriate label based on the provided floating point value.  If the
>> user wants to capture extra label information in this function (scale
>> magnitude, for example) they could do so.
>
> Speaking as someone who regularly prepares plots for scientific publication,
> having a custom labelling function for the axis labels would be great.
> Currently the bulk of my work isn't done using plplot but rather with a
> custom plotting framework I wrote around plotutils, but as part of that API
> I included precisely this functionality because I was always needing to
> label things with something apart from just the literal numeric value.

Given that bit of encouragement and my own use for such functionality,
I have started digging in to plbox.c to see what needs to happen.  As
it looks right now, the changes seem fairly straightforward.  To avoid
breaking the API, I think the simplest thing to do is to define a
plslabelfunc(labelf) function, with labelf having a signature similar
to:

void labelf(PLINT xyz, PLFLT value, PLINT scale, PLINT precision,
char* string, PLINT len, PLINT ll, PLINT lf);

Arguments:
- xyz: Is this a label for the X, Y or Z axis?
- value: The axis value to generate a label from
- scale, precision, ll, lf: See plform in plbox.c.  These could be
used or ignored by labelf
- string: This holds the text of the label to render (plmtex formatting)
- len: Maximum length of string

plslabelfunc(labelf) would then associate labelf with the current plot
stream.  Any calls to plbox/plaxes which request a custom x or y (or
z?) axis label would use labelf rather than the defaults in plbox to
get the string representation of the numeric label.  If no custom
label function is defined then the code could either use plabort or
just silently fall back on the default labeling system.  Clearing
custom label functions would require calling plslabelfunc(NULL).  The
changes to existing functions plbox.c would be fairly noninvasive,
just the addition of a few more variables and if-branches.

To sum up:
1) This would add one new function to the public PLplot API: plslabelfunc()
2) New constants could be added as well for the xyz argument described above
3) This would add 2 (3) new letters to the format string taken by
plbox (plbox3).  I propose "x" "y" and "z" for custom X, Y and Z axes,
respectively.
4) This should not change any existing code - everything which does
not use plslabelfunc() would continue to function as-is.

Does this seem like a reasonable approach?  Any suggestions for
improvements?  Is plslabelfunc an acceptable name or is there
something better anyone wants to suggest?  I don't mind more verbose
function names (pl_set_label_function) but the existing PLplot API
tends to be pretty terse.

If this is ok'd by the powers that be I am willing to work on this
during the 5.9.4 development period.

Hez

--
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science

------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to