|
From: <md...@us...> - 2010-10-06 16:57:22
|
Revision: 8731
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8731&view=rev
Author: mdboom
Date: 2010-10-06 16:57:16 +0000 (Wed, 06 Oct 2010)
Log Message:
-----------
[3081451] symlog doesn't handle values <1.0 correctly
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/scale.py
trunk/matplotlib/lib/matplotlib/ticker.py
Modified: trunk/matplotlib/lib/matplotlib/scale.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/scale.py 2010-10-06 16:03:48 UTC (rev 8730)
+++ trunk/matplotlib/lib/matplotlib/scale.py 2010-10-06 16:57:16 UTC (rev 8731)
@@ -6,6 +6,7 @@
from cbook import dedent
from ticker import NullFormatter, ScalarFormatter, LogFormatterMathtext, Formatter
from ticker import NullLocator, LogLocator, AutoLocator, SymmetricalLogLocator, FixedLocator
+from ticker import is_decade
from transforms import Transform, IdentityTransform
from matplotlib import docstring
@@ -318,19 +319,22 @@
def __init__(self, base, linthresh):
Transform.__init__(self)
self.base = base
- self.linthresh = linthresh
+ self.linthresh = abs(linthresh)
self._log_base = np.log(base)
- self._linadjust = (np.log(linthresh) / self._log_base) / linthresh
+ self._logb_linthresh = np.log(linthresh) / self._log_base
+ self._logb_minlog = np.floor(self._logb_linthresh - 1e-10)
+ self._linadjust = np.abs((np.log(linthresh) - self._logb_minlog) /
+ linthresh)
def transform(self, a):
a = np.asarray(a)
sign = np.sign(a)
masked = ma.masked_inside(a, -self.linthresh, self.linthresh, copy=False)
- log = sign * ma.log(np.abs(masked)) / self._log_base
+ log = sign * (ma.log(np.abs(masked)) / self._log_base - self._logb_minlog)
if masked.mask.any():
return np.asarray(ma.where(masked.mask,
- a * self._linadjust,
- log))
+ a * self._linadjust,
+ log))
else:
return np.asarray(log)
Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py 2010-10-06 16:03:48 UTC (rev 8730)
+++ trunk/matplotlib/lib/matplotlib/ticker.py 2010-10-06 16:57:16 UTC (rev 8731)
@@ -1180,20 +1180,20 @@
'floor x to the nearest lower decade'
if x == 0.0:
return -base
- lx = math.floor(math.log(x)/math.log(base))
+ lx = np.floor(np.log(x)/np.log(base))
return base**lx
def decade_up(x, base=10):
'ceil x to the nearest higher decade'
if x == 0.0:
return base
- lx = math.ceil(math.log(x)/math.log(base))
+ lx = np.ceil(np.log(x)/np.log(base))
return base**lx
def is_decade(x,base=10):
if x == 0.0:
return True
- lx = math.log(x)/math.log(base)
+ lx = np.log(x)/np.log(base)
return lx==int(lx)
class LogLocator(Locator):
@@ -1268,15 +1268,12 @@
stride += 1
decades = np.arange(math.floor(vmin),
- math.ceil(vmax)+stride, stride)
+ math.ceil(vmax)+stride, stride)
+ ticklocs = self._transform.inverted().transform(decades)
if len(subs) > 1 or (len(subs == 1) and subs[0] != 1.0):
- ticklocs = []
- for decadeStart in b**decades:
- ticklocs.extend( subs*decadeStart )
- else:
- ticklocs = b**decades
+ ticklocs = np.ravel(np.outer(subs, ticklocs))
- return self.raise_if_exceeds(np.array(ticklocs))
+ return self.raise_if_exceeds(np.asarray(ticklocs))
def view_limits(self, vmin, vmax):
'Try to choose the view limits intelligently'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|