8000 Fixed log scaling again. · matplotlib/matplotlib@8327bd4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8327bd4

Browse files
committed
Fixed log scaling again.
svn path=/branches/transforms/; revision=3886
1 parent 84f10e1 commit 8327bd4

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

lib/matplotlib/scale.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self, viewLim, direction, base):
2323
self._base = base
2424
self._viewLim = viewLim
2525
self._direction = direction
26+
self.set_children(['_viewLim'])
2627

2728
def transform(self, a):
2829
a, affine = self.transform_without_affine(a)
@@ -31,13 +32,9 @@ def transform(self, a):
3132
def transform_without_affine(self, a):
3233
# MGDTODO: Support different bases
3334
base = self._base
34-
marray = ma.masked_where(a <= 0.0, a)
35+
marray = ma.masked_where(a <= 0.0, a * 10.0)
3536
marray = npy.log10(marray)
36-
minimum, maximum = getattr(self._viewLim, self._direction)
37-
minimum, maximum = npy.log10([minimum, maximum])
38-
print marray
39-
print Affine1D.from_values(maximum - minimum, minimum).inverted()
40-
print minimum, maximum
37+
minimum, maximum = npy.log10(getattr(self._viewLim, self._direction) * 10.0)
4138
return marray, Affine1D.from_values(maximum - minimum, minimum).inverted()
4239

4340
def inverted(self):
@@ -51,11 +48,12 @@ def __init__(self, viewLim, direction, base):
5148
self._base = base
5249
self._viewLim = viewLim
5350
self._direction = direction
54-
51+
self.set_children(['_viewLim'])
52+
5553
def transform(self, a):
56-
minimum, maximum = getattr(self._viewLim, self._direction)
57-
Affine1D.from_values(maximum - minimum, minimum).transform(a)
58-
return ma.power(10.0, a)
54+
minimum, maximum = npy.log10(getattr(self._viewLim, self._direction) * 10.0)
55+
a = Affine1D.from_values(maximum - minimum, minimum).transform(a)
56+
return ma.power(10.0, a) / 10.0
5957

6058
def inverted(self):
6159
return LogScale.LogTransform(self._viewLim, self._direction, self._base)

lib/matplotlib/ticker.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -928,15 +928,19 @@ def autoscale(self):
928928
# if minpos<=0:
929929
# raise RuntimeError('No positive data to plot')
930930

931-
minpos = max(vmin, 0.00001) #MGDTODO
932-
if vmin<=0:
933-
vmin = minpos
931+
# MGDTODO: Find a good way to track minpos
932+
if vmin <= 0.0:
933+
vmin = 0.1
934+
934935
if not is_decade(vmin,self._base): vmin = decade_down(vmin,self._base)
935936
if not is_decade(vmax,self._base): vmax = decade_up(vmax,self._base)
936937
if vmin==vmax:
937938
vmin = decade_down(vmin,self._base)
938939
vmax = decade_up(vmax,self._base)
939-
return mtransforms.nonsingular(vmin, vmax)
940+
print vmin, vmax
941+
result = mtransforms.nonsingular(vmin, vmax)
942+
print result
943+
return result
940944

941945
class AutoLocator(MaxNLocator):
942946
def __init__(self):

lib/matplotlib/transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class Bbox(BboxBase):
181181
def __init__(self, points):
182182
BboxBase.__init__(self)
183183
self._points = npy.asarray(points, npy.float_)
184-
184+
185185
#@staticmethod
186186
def unit():
187187
return Bbox.from_lbrt(0., 0., 1., 1.)

0 commit comments

Comments
 (0)
0