From: <ef...@us...> - 2010-05-30 23:58:33
|
Revision: 8348 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8348&view=rev Author: efiring Date: 2010-05-30 23:58:27 +0000 (Sun, 30 May 2010) Log Message: ----------- LogNorm.autoscale ignores nonpositive values; closes 2953069 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/colors.py Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2010-05-30 21:31:19 UTC (rev 8347) +++ trunk/matplotlib/lib/matplotlib/colors.py 2010-05-30 23:58:27 UTC (rev 8348) @@ -850,6 +850,8 @@ vtype = 'scalar' val = ma.array([value]).astype(np.float) + val = ma.masked_less_equal(val, 0, copy=False) + self.autoscale_None(val) vmin, vmax = self.vmin, self.vmax if vmin > vmax: @@ -879,6 +881,24 @@ else: return vmin * pow((vmax/vmin), value) + def autoscale(self, A): + ''' + Set *vmin*, *vmax* to min, max of *A*. + ''' + A = ma.masked_less_equal(A, 0, copy=False) + self.vmin = ma.min(A) + self.vmax = ma.max(A) + + def autoscale_None(self, A): + ' autoscale only None-valued vmin or vmax' + if self.vmin is not None and self.vmax is not None: + return + A = ma.masked_less_equal(A, 0, copy=False) + if self.vmin is None: + self.vmin = ma.min(A) + if self.vmax is None: + self.vmax = ma.max(A) + class BoundaryNorm(Normalize): ''' Generate a colormap index based on discrete intervals. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |