SourceForge has been redesigned. Learn more.
Close

#381 %c working with non-linear units

5.0
open
nobody
None
5
2014-03-16
2014-03-15
Anonymous
No

The %c format specifiers for formatting axis tics is awesome but it may lack an issue.

Assume a=1345.13 and you want to output it as "%g%cm" where m is a literal that stands for meter (the unit). You get 1.34513km. Good.

Now you want to output a as "%g%cm^{-1}" you still get 1.344513km^{-1}. Under SI rules, it should read 1.344513mm^{-1} since it is understood that the exponent always alters both the unit (meter) and the prefix (milli).

Sort of an modifiers for %c may easily solve this problem. For instance the modifier - so that %-c may alter the behaviour of %c: when catching the scientific power (3 in the example), change sign (-3) and get the appropriate character replacement for scientific power.

Some complexities arise if the exponent is other than -1. If you want to output "%g%cm^2" the gnuplot solution 1.34513km^2 is not good either. However I can't hardly see any comprehensive solution to m^2 or m^3 if your character replacement jumps in three orders of magnitude (that makes 6 orders of magnitude for m^2 and 9 orders for m^3). In this case you just shouldn't take advantage of the %c format specifier.

However, the case m^{-1} is easily solvable and could be frequently used.

I attach an example using:
set format x "%.s%cJ"
set format y "%.s%cJ^{-1}"
set logscale x
set logscale y 1000

Char replacentment in the y-axis should read, from low to high, 1GJ^{-1}, 1MJ^{-1}, 1 kJ^{-1} and 1J^{-1}. X-axis shows energy, Y-axis density of probability

1 Attachments

Discussion

  • Bastian Märkisch

    In my opinion this is more a feature request than a bug.
    Ethan, could you please move this tracker item?

     
  • Ethan Merritt

    Ethan Merritt - 2014-03-16

    Ticket moved from /p/gnuplot/bugs/1357/

     

Log in to post a comment.