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 - New Free Runtime and 30 Day Trial Check out the new simplified licensign option that enables unlimited royalty-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