Jean-Baptiste> S?ll ! I am trying to plot very small number for
Jean-Baptiste> the Y-axis on semilogy but they do not appear at
Jean-Baptiste> all unless one of the value is higher Moreover the
Jean-Baptiste> labels on the Y axis become 0 below 0.001
>>> semilogy([1.0, 2.3, 3.3],[9.4e-05, 9.4e-05, 9.4e-05]) <-- does
>>> not work
Jean-Baptiste> [<matplotlib.lines.Line2D instance at 0x935255c>]
>>> semilogy([1.0, 2.3, 3.3],[9.4e-04, 9.4e-05, 9.4e-05]) <---
>>> work
Jean-Baptiste> [<matplotlib.lines.Line2D instance at 0x940e964>]
S?ll Jean!
Thanks for this example. The relevant code which handles autoscaling
is in matplotlib.axis.autoscale_view. I wasn't handling the special
case where min=max for log scaling (though I do handle it for linear
scaling).
Try this replacement code for axis.py: and the functions decade_down
and decade_up and replace the autoscale_view function.
def decade_down(x):
'floor x to the nearest lower decade'
lx = math.floor(math.log10(x))
return 10**lx
def decade_up(x):
'ceil x to the nearest higher decade'
lx = math.ceil(math.log10(x))
return 10**lx
class Axis(Artist):
def autoscale_view(self):
'Try to choose the view limits intelligently'
vmin, vmax = self.datalim.bounds()
if self._scale=='linear':
if vmin==vmax:
vmin-=1
vmax+=1
try:
(exponent, remainder) = divmod(math.log10(vmax - vmin), 1)
except OverflowError:
print >>sys.stderr, 'Overflow error in autoscale', vmin, vmax
return
if remainder < 0.5:
exponent -= 1
scale = 10**(-exponent)
vmin = math.floor(scale*vmin)/scale
vmax = math.ceil(scale*vmax)/scale
self.viewlim.set_bounds(vmin, vmax)
elif self._scale=='log':
if vmin==vmax:
vmin = decade_down(vmin)
vmax = decade_up(vmax)
self.viewlim.set_bounds(vmin, vmax)
Let me know how this works for you,
JDH