|
From: Matt N. <new...@ca...> - 2005-02-25 16:11:58
|
> > 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?
More likely, the plot should be of 1-x, not x, with 1 subtracted
from the data before being sent to the plot. Would you use
seconds-since-1970 to make a plot versus Time with a range of 1
sec and data every millisecond? The data plotted should be the
"significant digits" after all.
FWIW, a custom tick formatter I've been using is below. It's a
slight variation on the default, and won't solve the space
needed to display "1 + n*1.e-9", but it will do a reasonable job
of picking the number of significant digits to show based on the
data range for the Axis. It could be expanded....
--Matt
! def myformatter(self, x=1.0, axis=None):
! """ custom tick formatter to use with FuncFormatter():
! x value to be formatted
! axis Axis instance to use for formatting
! """
! fmt = '%1.5g'
! if axis == None:
! return fmt % x
!
! # attempt to get axis span (range of values to format)
! delta = 0.2
! try:
! ticks = axis.get_major_locator()()
! delta = abs(ticks[1] - ticks[0])
! except:
! try:
! delta = 0.1 * axis.get_view_interval().span()
! except:
! pass
!
! if delta > 99999: fmt = '%1.6e'
! elif delta > 0.99: fmt = '%1.0f'
! elif delta > 0.099: fmt = '%1.1f'
! elif delta > 0.0099: fmt = '%1.2f'
! elif delta > 0.00099: fmt = '%1.3f'
! elif delta > 0.000099: fmt = '%1.4f'
! elif delta > 0.0000099: fmt = '%1.5f'
!
! s = fmt % x
! s.strip()
! s = s.replace('+', '')
! while s.find('e0')>0: s = s.replace('e0','e')
! while s.find('-0')>0: s = s.replace('-0','-')
!
! return s
|