Salut Tom,
On 25.04.07, Thomas Kornack wrote:
> I'm curious how I might implement an axis with metric prefixes such
> as milli micro nano pico femto? In particular, I commonly work
> in units of Tesla over a broad range from attoTesla (aT), femtoTesla
> (fT), picoTesla (pT) to nanoTesla (nT). I would like to make a graph
> axis that is labeled as follows: 1 aT, 10 aT, 100 aT, 1 fT, 10 fT,
> 100 fT, 1 pT and so on. Any suggestions? Thanks in advance!
Personally, I would prefer a dimensionless log axis with only the
exponents written at the ticks.
But, I was also curious how to implement this. The following dirty
trick overwrites the modulo function of the default strings. I took
the log.py example as a base, never mind the curved axis.

import math
from pyx import *
from pyx.graph import axis
text.set(mode="latex")
class mystr(str):
prefixes = [
(3, r"\mbox{M}"),
(0, ""),
(1, r"\mbox{d}"),
(2, r"\mbox{c}"),
(3, r"\mbox{m}"),
(6, r"\mu{}"),
(9, r"\mbox{n}"),
(12, r"\mbox{p}"),
(15, r"\mbox{f}"),
(18, r"\mbox{a}")]
def __mod__(self, otherstr):
other = int(otherstr)
for expon, pref in self.prefixes:
if other >= expon:
break
o, p = other, pref
return r"%d\,%s\mbox{T}" % (10**(otherexpon), pref)
p = path.curve(0, 0, 3, 0, 1, 4, 4, 4)
mytexter = axis.texter.exponential(nomantissaexp=mystr())
c = canvas.canvas()
c.insert(axis.pathaxis(p, axis.log(min=1e16, max=1, texter=mytexter)))
c.writeEPSfile("log")
c.writePDFfile("log")

Michael.
