|
From: John H. <jdh...@ac...> - 2005-02-25 04:14:22
|
>>>>> "Hans" == Hans Fangohr <H.F...@so...> writes:
Hans> x=pylab.arange(0,1e-8,1e-9)+1.0 pylab.plot(x) pylab.show()
Hans> All works fine when I subtract the mean of x but there seems
Hans> to be a problem with labelling axes for plotted data which
Hans> is not close to zero but shows only small variations.
I agree it's a bug. It's not immediately clear to me what the labels
should be though
1.0000000002
1.0000000004
1.0000000006
and so on? That takes up a lot of room. Granted, correct but ugly
is better than incorrect but pretty, but I'm curious if there is a
better way to format these cases. Perhaps ideal would be an indicator
at the bottom or top of the y axis that read '1+' and then use 2e-9,
4e-9, etc as the actual tick labels. Do you agree this is ideal?
To achieve this, as you may know, you can pass in a custom tick
formatter. Eg
import pylab
def myformatter(x, pos):
return '%1.0e'%(x-1)
ax = pylab.subplot(111)
x=pylab.arange(0,1e-8,1e-9)+1.0
ax.plot(x)
formatter = pylab.FuncFormatter(myformatter)
ax.yaxis.set_major_formatter(formatter)
ax.text(-.125, 1.025, '1+', transform=ax.transAxes)
pylab.show()
See also examples/custom_ticker1.py.
This is not to say that I don't want to fix this bug; I just wanted to
make sure you are aware of this workaround.
JDH
|